Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
whazlewo opened this issue Jul 22, 2024 · 0 comments
Open

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

whazlewo opened this issue Jul 22, 2024 · 0 comments

Comments

@whazlewo
Copy link

whazlewo commented Jul 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant