s3: fix exists check
This commit is contained in:
@@ -153,10 +153,10 @@ async function exists(apiConfig, backupFilePath) {
|
||||
Key: backupFilePath
|
||||
};
|
||||
|
||||
const [error] = await safe(s3.headObject(params).promise());
|
||||
if (!Object.keys(this.httpResponse.headers).some(h => h.startsWith('x-amz'))) throw new BoxError(BoxError.EXTERNAL_ERROR, 'not a s3 endpoint');
|
||||
const [error, response] = await safe(s3.headObject(params).promise());
|
||||
if (error && S3_NOT_FOUND(error)) return false;
|
||||
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Error headObject ${backupFilePath}. Message: ${error.message} HTTP Code: ${error.code}`);
|
||||
if (!response || typeof response.Metadata !== 'object') throw new BoxError(BoxError.EXTERNAL_ERROR, 'not a s3 endpoint');
|
||||
|
||||
return true;
|
||||
} else { // list dir contents
|
||||
|
||||
Reference in New Issue
Block a user