fix(fs/s3#copy): normalize error: no such key → ENOENT (#6388)

This commit is contained in:
Florent BEAUCHAMP 2022-09-01 12:51:44 +02:00 committed by GitHub
parent dca3f39156
commit d8e01b2867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,6 +155,14 @@ export default class S3Handler extends RemoteHandlerAbstract {
if (e.name === 'EntityTooLarge') {
return this._multipartCopy(oldPath, newPath)
}
// normalize this error code
if (e.name === 'NoSuchKey') {
const error = new Error(`ENOENT: no such file or directory '${oldPath}'`)
error.cause = e
error.code = 'ENOENT'
error.path = oldPath
throw error
}
throw e
}
}