mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +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 = {},
|
metadata = {},
|
||||||
targetFilename,
|
targetFilename,
|
||||||
isDirectory,
|
isDirectory,
|
||||||
|
retryNumber = 0
|
||||||
}) {
|
}) {
|
||||||
if (isDirectory) {
|
if (isDirectory) {
|
||||||
let files = await fs.promises.readdir(source)
|
let files = await fs.promises.readdir(source)
|
||||||
@ -39,6 +40,7 @@ export default async function b2Upload({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
await global.b2Storage.authorize()
|
await global.b2Storage.authorize()
|
||||||
|
|
||||||
if (!fs.existsSync(source)) {
|
if (!fs.existsSync(source)) {
|
||||||
@ -63,6 +65,22 @@ export default async function b2Upload({
|
|||||||
data: data,
|
data: data,
|
||||||
info: metadata
|
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 {
|
return {
|
||||||
id: remotePath,
|
id: remotePath,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user