Skip to content

Can't seem to make --delete work on sync. #69

@whazlewo

Description

@whazlewo

I'm still getting acquainted with managing s3 buckets programaticaly so bare with me...

I've written the following function using this lib:

/**
 * Syncs a directory to an S3 bucket.
 *
 * @param syncFrom The local directory path to sync from.
 * @param syncTo The S3 bucket path to sync to.
 * @returns A Promise that resolves when the sync is complete.
 */
const syncDirectoryToS3 = async (syncFrom: string, syncTo: string): Promise<void> => {
  // Sync wrapper for S3 Client
  // www.npmjs.com/package/s3-sync-client
  const {sync} = new S3SyncClient({client: new S3Client(AWS_CREDS)});
  
  // Command input for content type
  const commandInput = (input: any) => ({ContentType: mime.lookup(input.Key) || 'text/html'});
  
  // Event listener for progress updates
  const monitor = new TransferMonitor().on('progress', progress => progressUpdate(progress));
  
  // Run sync command and update on progress
  await sync(syncFrom, syncTo, {del: true, commandInput, monitor});
  console.log(`\nTransfer complete: ${syncTo} is now synced with files from ${syncFrom}`);
};

I have del: true right there in the call to sync() at the end, but for some reason when I delete files locally and sync, they are still in the s3 bucket... anyone see anything overtly with this function?

How I tested:

  1. Create folder foo locally and touch file1.txt file2.txt
  2. Run sync command above
  3. List contents of foo
  4. Delete file1.txt locally
  5. Run sync command above
  6. List contents of foo

file1.txt is still in the s3 bucket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions