@alexbainter/s3-sync
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -6,2 +6,4 @@ 'use strict'; | ||
const MAX_OBJECT_COUNT_PER_REQUEST = 1000; | ||
const pruneRemote = ({ | ||
@@ -35,10 +37,27 @@ s3, | ||
return (dryRun | ||
? Promise.resolve() | ||
: s3 | ||
.deleteObjects({ | ||
Delete: { Objects: deleteFilenames.map((key) => ({ Key: key })) }, | ||
const deleteGroups = deleteFilenames.reduce( | ||
(groups, filename, i) => { | ||
const groupIndex = Math.floor(i / MAX_OBJECT_COUNT_PER_REQUEST); | ||
groups[groupIndex].push(filename); | ||
return groups; | ||
}, | ||
Array.from( | ||
{ | ||
length: Math.ceil( | ||
deleteFilenames.length / MAX_OBJECT_COUNT_PER_REQUEST | ||
), | ||
}, | ||
() => [] | ||
) | ||
); | ||
const deleteRequests = deleteGroups.map((filenames) => | ||
dryRun | ||
? Promise.resolve() | ||
: s3.deleteObjects({ | ||
Delete: { Objects: filenames.map((key) => ({ Key: key })) }, | ||
}) | ||
.promise() | ||
).then(() => { | ||
); | ||
return Promise.all(deleteRequests).then(() => { | ||
console.log( | ||
@@ -45,0 +64,0 @@ `Removed ${deleteFilenames.length} files:\n${deleteFilenames.join( |
{ | ||
"name": "@alexbainter/s3-sync", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Transfer files to and from S3", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22755
595