fix: use overwrite to make metadata files work

During a delete the metadata file is updated. As the overwrite property was not set, the metadata
couldn't be updated and caused issues.
This commit is contained in:
2024-11-18 21:08:39 +00:00
parent cec9c07b7c
commit 8d160cefb0
4 changed files with 39 additions and 22 deletions

View File

@@ -331,7 +331,9 @@ export class Bucket {
}): Promise<void> {
try {
const destinationBucket = optionsArg.targetBucket || this;
const exists = await destinationBucket.fastExists({ path: optionsArg.destinationPath });
const exists = await destinationBucket.fastExists({
path: optionsArg.destinationPath,
});
if (exists && !optionsArg.overwrite) {
console.error(
@@ -424,8 +426,8 @@ export class Bucket {
Prefix: checkPath,
Delimiter: '/',
});
const response = await this.smartbucketRef.s3Client.send(command);
return response.CommonPrefixes.length > 0;
const { CommonPrefixes } = await this.smartbucketRef.s3Client.send(command);
return !!CommonPrefixes && CommonPrefixes.length > 0;
}
public async isFile(pathDescriptor: interfaces.IPathDecriptor): Promise<boolean> {
@@ -435,8 +437,8 @@ export class Bucket {
Prefix: checkPath,
Delimiter: '/',
});
const response = await this.smartbucketRef.s3Client.send(command);
return response.Contents.length > 0;
const { Contents } = await this.smartbucketRef.s3Client.send(command);
return !!Contents && Contents.length > 0;
}
public async getMagicBytes(optionsArg: { path: string; length: number }): Promise<Buffer> {
@@ -449,7 +451,7 @@ export class Bucket {
const response = await this.smartbucketRef.s3Client.send(command);
const chunks = [];
const stream = response.Body as any; // SdkStreamMixin includes readable stream
for await (const chunk of stream) {
chunks.push(chunk);
}