From 7245b49c31dd911f61047abe038e4f92dbc252b4 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Tue, 11 Jun 2024 17:20:48 +0200 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/classes.directory.ts | 45 ++++++++++++++++++++++++++-------------- ts/classes.trash.ts | 5 ++++- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5f96764..a0ab2e8 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartbucket', - version: '3.0.13', + version: '3.0.14', description: 'A TypeScript library offering simple and cloud-agnostic object storage with advanced features like bucket creation, file and directory management, and data streaming.' } diff --git a/ts/classes.directory.ts b/ts/classes.directory.ts index e9c6981..c1c78b2 100644 --- a/ts/classes.directory.ts +++ b/ts/classes.directory.ts @@ -79,7 +79,10 @@ export class Directory { }); if (!exists && optionsArg.getFromTrash) { const trash = await this.bucketRef.getTrash(); - const trashKey = await trash.getTrashKeyByOriginalBasePath() + const trashedFile = await trash.getTrashedFileByOriginalName( + pathDescriptor + ) + return trashedFile; } if (!exists && !optionsArg.createWithContents) { return null; @@ -94,7 +97,7 @@ export class Directory { return new File({ directoryRefArg: this, fileName: optionsArg.name, - }) + }); } /** @@ -132,7 +135,7 @@ export class Directory { }, finalFunction: async (tools) => { done.resolve(); - } + }, }); fileNameStream.pipe(duplexStream); await done.promise; @@ -171,7 +174,7 @@ export class Directory { }, finalFunction: async (tools) => { done.resolve(); - } + }, }); completeDirStream.pipe(duplexStream); await done.promise; @@ -246,23 +249,35 @@ export class Directory { return result; } - public fastGetStream(optionsArg: { - path: string; - }, typeArg: 'webstream'): Promise - public async fastGetStream(optionsArg: { - path: string; - }, typeArg: 'nodestream'): Promise + public fastGetStream( + optionsArg: { + path: string; + }, + typeArg: 'webstream' + ): Promise; + public async fastGetStream( + optionsArg: { + path: string; + }, + typeArg: 'nodestream' + ): Promise; /** * fastGetStream * @param optionsArg - * @returns + * @returns */ - public async fastGetStream(optionsArg: { path: string; }, typeArg: 'webstream' | 'nodestream'): Promise{ + public async fastGetStream( + optionsArg: { path: string }, + typeArg: 'webstream' | 'nodestream' + ): Promise { const path = plugins.path.join(this.getBasePath(), optionsArg.path); - const result = await this.bucketRef.fastGetStream({ - path - }, typeArg as any); + const result = await this.bucketRef.fastGetStream( + { + path, + }, + typeArg as any + ); return result; } diff --git a/ts/classes.trash.ts b/ts/classes.trash.ts index ce9bf05..f42e854 100644 --- a/ts/classes.trash.ts +++ b/ts/classes.trash.ts @@ -18,7 +18,10 @@ export class Trash { } public async getTrashedFileByOriginalName(pathDescriptor: interfaces.IPathDecriptor): Promise { - + const trashDir = await this.getTrashDir(); + const originalPath = await helpers.reducePathDescriptorToPath(pathDescriptor); + const trashKey = await this.getTrashKeyByOriginalBasePath(originalPath); + return trashDir.getFile({ name: trashKey }); } public async getTrashKeyByOriginalBasePath (originalPath: string): Promise {