@adobe/aio-lib-web 7.0.3 → 7.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/remote-storage.js +25 -15
- package/package.json +1 -1
package/lib/remote-storage.js
CHANGED
|
@@ -245,21 +245,31 @@ module.exports = class RemoteStorage {
|
|
|
245
245
|
// walk the whole directory recursively using klaw.
|
|
246
246
|
const files = await this.walkDir(dir)
|
|
247
247
|
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
248
|
+
// we will upload files in batches of 50 to prevent warnings about enqued tasks.
|
|
249
|
+
// this happens based on the default maxSockets value of 50 in node.js but we cannot change
|
|
250
|
+
// the user's default value.
|
|
251
|
+
// less than 1% of users will see this warning, but it is better to prevent it.
|
|
252
|
+
const batchSize = 50
|
|
253
|
+
let fileBatch = files.splice(0, batchSize)
|
|
254
|
+
const allResults = []
|
|
255
|
+
while (fileBatch.length > 0) {
|
|
256
|
+
const res = await Promise.all(fileBatch.map(async f => {
|
|
257
|
+
// get file's relative folder to the base directory.
|
|
258
|
+
let prefixDirectory = path.dirname(path.relative(dir, f))
|
|
259
|
+
// base directory returns ".", ignore that.
|
|
260
|
+
prefixDirectory = prefixDirectory === '.' ? '' : prefixDirectory
|
|
261
|
+
// newPrefix is now the initial prefix plus the files relative directory path.
|
|
262
|
+
const newPrefix = urlJoin(prefix, prefixDirectory)
|
|
263
|
+
const s3Res = await this.uploadFile(f, newPrefix, appConfig, dir)
|
|
264
|
+
if (postFileUploadCallback) {
|
|
265
|
+
postFileUploadCallback(f)
|
|
266
|
+
}
|
|
267
|
+
return s3Res
|
|
268
|
+
}))
|
|
269
|
+
allResults.push(res)
|
|
270
|
+
fileBatch = files.splice(0, batchSize)
|
|
271
|
+
}
|
|
272
|
+
return allResults
|
|
263
273
|
}
|
|
264
274
|
|
|
265
275
|
/**
|