mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Preserve all error information when cleanup of copied file fails
This commit is contained in:
parent
b4b7fd226e
commit
5d5d325691
1 changed files with 15 additions and 17 deletions
|
@ -111,22 +111,7 @@ module.exports = function(primary, fallback) {
|
||||||
|
|
||||||
await primary.promises.sendStream(destBucket, destKey, stream, sourceMd5)
|
await primary.promises.sendStream(destBucket, destKey, stream, sourceMd5)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let error = err
|
const error = new WriteError({
|
||||||
metrics.inc('fallback.copy.failure')
|
|
||||||
|
|
||||||
try {
|
|
||||||
await primary.promises.deleteFile(destBucket, destKey)
|
|
||||||
} catch (err) {
|
|
||||||
error = new WriteError({
|
|
||||||
message: 'unable to clean up destination copy artifact',
|
|
||||||
info: {
|
|
||||||
destBucket,
|
|
||||||
destKey
|
|
||||||
}
|
|
||||||
}).withCause(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
error = new WriteError({
|
|
||||||
message: 'unable to copy file to destination persistor',
|
message: 'unable to copy file to destination persistor',
|
||||||
info: {
|
info: {
|
||||||
sourceBucket,
|
sourceBucket,
|
||||||
|
@ -134,7 +119,20 @@ module.exports = function(primary, fallback) {
|
||||||
sourceKey,
|
sourceKey,
|
||||||
destKey
|
destKey
|
||||||
}
|
}
|
||||||
}).withCause(error)
|
}).withCause(err)
|
||||||
|
metrics.inc('fallback.copy.failure')
|
||||||
|
|
||||||
|
try {
|
||||||
|
await primary.promises.deleteFile(destBucket, destKey)
|
||||||
|
} catch (err) {
|
||||||
|
error.info.cleanupError = new WriteError({
|
||||||
|
message: 'unable to clean up destination copy artifact',
|
||||||
|
info: {
|
||||||
|
destBucket,
|
||||||
|
destKey
|
||||||
|
}
|
||||||
|
}).withCause(err)
|
||||||
|
}
|
||||||
|
|
||||||
logger.warn({ error }, 'failed to copy file from fallback')
|
logger.warn({ error }, 'failed to copy file from fallback')
|
||||||
throw error
|
throw error
|
||||||
|
|
Loading…
Reference in a new issue