Skip to main content
← Back to list
01Issue
FeatureOpenSwamp CLIPublic
AssigneesNone

Relationships

#1670 datastore setup: symlinks not counted in bytesCopied, causing misleading '(0B)' output

Opened by stack72 · 8/15/2026

Summary

swamp datastore setup reports Files: 14062 copied (0B) even when thousands of files are successfully migrated. The (0B) is not a display rounding issue — bytesCopied genuinely stays at 0.

Root Cause

In src/domain/datastore/datastore_migration_service.ts, the copyDirectory function has two branches:

  • Regular files (line 106–107): correctly increments both filesCopied and bytesCopied += stat.size
  • Symlinks (line 136): increments filesCopied only — bytesCopied is never updated

Swamp's datastore uses symlinks heavily for "latest version" pointers (e.g. latest → 1). These are converted to text files during migration via Deno.writeTextFile(destPath, numeric.toString()), but their byte contribution is never recorded.

// line 115–136 (simplified)
} else if (entry.isSymlink) {
  const target = await Deno.readLink(srcPath);
  const numeric = parseInt(target.replace(/\/$/, ""), 10);
  if (!isNaN(numeric)) {
    await Deno.writeTextFile(destPath, numeric.toString());
  } else {
    await Deno.symlink(target, destPath, { type: linkType });
  }
  result.filesCopied++;
  // ← bytesCopied never updated here
}

Fix

Add result.bytesCopied += target.length in the symlink branch, after the successful write:

result.filesCopied++;
result.bytesCopied += target.length; // content written is the target string

Observed Behaviour

Datastore Setup Complete
  Type:     @swamp/s3-datastore
  Files:    14062 copied (0B)   ← misleading: data was transferred, bytes just aren't counted
  Hydrated: 0 pulled

Expected Behaviour

Datastore Setup Complete
  Type:     @swamp/s3-datastore
  Files:    14062 copied (14.0KB)   ← or similar, reflecting symlink content written to disk
  Hydrated: 0 pulled

Environment

  • swamp: current main (a648c130)
  • datastore: @swamp/s3-datastore 2026.08.12.1
  • Reproduced on macOS (Mehri) migrating a local-filesystem datastore to S3/B2

Automoved by swampadmin from https://github.com/swamp-club/swamp/issues/2156

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

8/15/2026, 6:40:09 AM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.