mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 14:00:51 +00:00
Make 404 error handling on deletes more specific
The GCS persistor error handler ignores 404 errors on deletes. However, the net is too wide cast, and 404 errors coming from the dual-bucket lifecycle mechanism are also ignored.
This commit is contained in:
parent
9f28adf96c
commit
0fdfa706f7
1 changed files with 9 additions and 5 deletions
|
@ -200,17 +200,21 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
|||
if (this.settings.unlockBeforeDelete) {
|
||||
await file.setMetadata({ eventBasedHold: false })
|
||||
}
|
||||
await file.delete()
|
||||
try {
|
||||
await file.delete()
|
||||
} catch (err) {
|
||||
// ignore 404s: it's fine if the file doesn't exist.
|
||||
if (err.code !== 404) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
const error = PersistorHelper.wrapError(
|
||||
throw PersistorHelper.wrapError(
|
||||
err,
|
||||
'error deleting GCS object',
|
||||
{ bucketName, key },
|
||||
WriteError
|
||||
)
|
||||
if (!(error instanceof NotFoundError)) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue