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

@@ -92,16 +92,13 @@ export class File {
/**
* deletes this file
*/
public async delete(optionsArg?: {
mode: 'trash' | 'permanent';
}) {
public async delete(optionsArg?: { mode: 'trash' | 'permanent' }) {
optionsArg = {
... {
...{
mode: 'permanent',
},
...optionsArg,
}
};
if (optionsArg.mode === 'permanent') {
await this.parentDirectoryRef.bucketRef.fastRemove({
@@ -126,7 +123,7 @@ export class File {
path: await trash.getTrashKeyByOriginalBasePath(this.getBasePath()),
});
}
await this.parentDirectoryRef.listFiles();
}
@@ -169,16 +166,19 @@ export class File {
await this.parentDirectoryRef.bucketRef.fastPutStream({
path: this.getBasePath(),
readableStream: optionsArg.contents,
overwrite: true,
});
} else if (Buffer.isBuffer(optionsArg.contents)) {
await this.parentDirectoryRef.bucketRef.fastPut({
path: this.getBasePath(),
contents: optionsArg.contents,
overwrite: true,
});
} else if (typeof optionsArg.contents === 'string') {
await this.parentDirectoryRef.bucketRef.fastPut({
path: this.getBasePath(),
contents: Buffer.from(optionsArg.contents, optionsArg.encoding),
overwrite: true,
});
}
}
@@ -238,7 +238,7 @@ export class File {
public async getMagicBytes(optionsArg: { length: number }): Promise<Buffer> {
return this.parentDirectoryRef.bucketRef.getMagicBytes({
path: this.getBasePath(),
length: optionsArg.length
})
length: optionsArg.length,
});
}
}