finish trash

This commit is contained in:
2024-06-10 16:47:20 +02:00
parent 9629a04da6
commit 4b70edb947
7 changed files with 178 additions and 97 deletions

View File

@@ -2,6 +2,8 @@ import * as plugins from './plugins.js';
import { Bucket } from './classes.bucket.js';
import { File } from './classes.file.js';
import * as helpers from './helpers.js';
export class Directory {
public bucketRef: Bucket;
public parentDirectoryRef: Directory;
@@ -65,11 +67,20 @@ export class Directory {
public async getFile(optionsArg: {
name: string;
createWithContents?: string | Buffer;
getFromTrash?: boolean;
}): Promise<File> {
const pathDescriptor = {
directory: this,
path: optionsArg.name,
};
// check wether the file exists
const exists = await this.bucketRef.fastExists({
path: this.getBasePath() + optionsArg.name,
path: await helpers.reducePathDescriptorToPath(pathDescriptor),
});
if (!exists && optionsArg.getFromTrash) {
const trash = await this.bucketRef.getTrash();
const trashKey = await trash.getTrashKeyByOriginalBasePath()
}
if (!exists && !optionsArg.createWithContents) {
return null;
}