mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
support for upload retry
This commit is contained in:
parent
582c7e389b
commit
744b771d2b
@ -8,6 +8,7 @@ export default async function b2Upload({
|
||||
metadata = {},
|
||||
targetFilename,
|
||||
isDirectory,
|
||||
retryNumber = 0
|
||||
}) {
|
||||
if (isDirectory) {
|
||||
let files = await fs.promises.readdir(source)
|
||||
@ -39,6 +40,7 @@ export default async function b2Upload({
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await global.b2Storage.authorize()
|
||||
|
||||
if (!fs.existsSync(source)) {
|
||||
@ -63,6 +65,22 @@ export default async function b2Upload({
|
||||
data: data,
|
||||
info: metadata
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
if (retryNumber < 5) {
|
||||
return await b2Upload({
|
||||
source,
|
||||
remotePath,
|
||||
metadata,
|
||||
targetFilename,
|
||||
isDirectory,
|
||||
retryNumber: retryNumber + 1
|
||||
})
|
||||
}
|
||||
|
||||
throw new OperationError(500, "B2 upload failed")
|
||||
}
|
||||
|
||||
return {
|
||||
id: remotePath,
|
||||
|
Loading…
x
Reference in New Issue
Block a user