diff --git a/src/storage/gcs.js b/src/storage/gcs.js index 4e50579e4..be47ba18b 100644 --- a/src/storage/gcs.js +++ b/src/storage/gcs.js @@ -145,6 +145,7 @@ async function copy(apiConfig, oldFilePath, newFilePath, progressCallback) { let marker = null; while (true) { const batch = await listDir(apiConfig, oldFilePath, batchSize, marker); + if (batch.entries.length === 0) break; total += batch.entries.length; progressCallback({ message: `Copying ${batch.entries.length} files from ${batch.entries[0].fullPath} to ${batch.entries[batch.entries.length-1].fullPath}. total: ${total}` }); await async.eachLimit(batch.entries, concurrency, copyFile); @@ -173,6 +174,7 @@ async function removeDir(apiConfig, pathPrefix, progressCallback) { let marker = null; while (true) { const batch = await listDir(apiConfig, pathPrefix, batchSize, marker); + if (batch.entries.length === 0) break; const entries = batch.entries; total += entries.length; progressCallback({ message: `Removing ${entries.length} files from ${entries[0].fullPath} to ${entries[entries.length-1].fullPath}. total: ${total}` });