bumped padding of bundles to 6 digits
This commit is contained in:
parent
59d4d2c9e0
commit
53205ab661
4 changed files with 5 additions and 5 deletions
|
|
@ -60,7 +60,7 @@ function pickBundle() {
|
||||||
|
|
||||||
// Fetch a bundle JSON
|
// Fetch a bundle JSON
|
||||||
async function fetchBundle(idx) {
|
async function fetchBundle(idx) {
|
||||||
const padded = String(idx).padStart(4, "0");
|
const padded = String(idx).padStart(6, "0");
|
||||||
const resp = await fetch(`tabs/${padded}.json`);
|
const resp = await fetch(`tabs/${padded}.json`);
|
||||||
if (!resp.ok) throw new Error(`Failed to fetch bundle ${padded}`);
|
if (!resp.ok) throw new Error(`Failed to fetch bundle ${padded}`);
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,11 @@ func serializeBundle(entries []BundleEntry) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeBundleLocal(outputDir string, index int, data []byte) error {
|
func writeBundleLocal(outputDir string, index int, data []byte) error {
|
||||||
path := filepath.Join(outputDir, fmt.Sprintf("%04d.json", index))
|
path := filepath.Join(outputDir, fmt.Sprintf("%06d.json", index))
|
||||||
return os.WriteFile(path, data, 0644)
|
return os.WriteFile(path, data, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeBundleS3(bucket string, index int, data []byte) error {
|
func writeBundleS3(bucket string, index int, data []byte) error {
|
||||||
key := fmt.Sprintf("tabs/%04d.json", index)
|
key := fmt.Sprintf("tabs/%06d.json", index)
|
||||||
return s3UploadBundle(bucket, key, data)
|
return s3UploadBundle(bucket, key, data)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ func main() {
|
||||||
fmt.Printf(" %d/%d bundles\n", n, estimatedTotal)
|
fmt.Printf(" %d/%d bundles\n", n, estimatedTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
logLine := fmt.Sprintf("bundle: %04d.json %dKB", job.index, len(job.data)/1024)
|
logLine := fmt.Sprintf("bundle: %06d.json %dKB", job.index, len(job.data)/1024)
|
||||||
if logWriter != nil {
|
if logWriter != nil {
|
||||||
logWriter.Write(logLine, false)
|
logWriter.Write(logLine, false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ if [ "$OLD_TOTAL" -gt "$TOTAL_BUNDLES" ]; then
|
||||||
STALE_COUNT=$((OLD_TOTAL - TOTAL_BUNDLES))
|
STALE_COUNT=$((OLD_TOTAL - TOTAL_BUNDLES))
|
||||||
echo "Deleting $STALE_COUNT stale bundles ($TOTAL_BUNDLES to $((OLD_TOTAL - 1)))..."
|
echo "Deleting $STALE_COUNT stale bundles ($TOTAL_BUNDLES to $((OLD_TOTAL - 1)))..."
|
||||||
for i in $(seq "$TOTAL_BUNDLES" "$((OLD_TOTAL - 1))"); do
|
for i in $(seq "$TOTAL_BUNDLES" "$((OLD_TOTAL - 1))"); do
|
||||||
PADDED=$(printf "%04d" "$i")
|
PADDED=$(printf "%06d" "$i")
|
||||||
aws s3 rm "s3://$SITE_BUCKET/tabs/${PADDED}.json" --quiet
|
aws s3 rm "s3://$SITE_BUCKET/tabs/${PADDED}.json" --quiet
|
||||||
done
|
done
|
||||||
echo "Deleted $STALE_COUNT stale bundles"
|
echo "Deleted $STALE_COUNT stale bundles"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue