From 476ff5bbce5d67dda71068880cf5a05dd5eeb370 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 7 Apr 2021 18:42:03 +0000 Subject: [PATCH] fix(core): update --- ts/smartbucket.classes.bucket.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ts/smartbucket.classes.bucket.ts b/ts/smartbucket.classes.bucket.ts index e7f220d..8140c36 100644 --- a/ts/smartbucket.classes.bucket.ts +++ b/ts/smartbucket.classes.bucket.ts @@ -50,7 +50,7 @@ export class Bucket { /** * store file */ - public async fastStore(pathArg: string, fileContent: string) { + public async fastStore(pathArg: string, fileContent: string | Buffer): Promise { const streamIntake = new plugins.streamfunction.Intake(); const putPromise = this.smartbucketRef.minioClient .putObject(this.name, pathArg, streamIntake.getReadable()) @@ -63,11 +63,11 @@ export class Bucket { /** * get file */ - public async fastGet(pathArg: string) { + public async fastGet(pathArg: string): Promise { const done = plugins.smartpromise.defer(); let completeFile: Buffer; const replaySubject = await this.fastGetStream(pathArg); - replaySubject.subscribe( + const subscription = replaySubject.subscribe( (chunk) => { if (completeFile) { completeFile = Buffer.concat([completeFile, chunk]); @@ -78,6 +78,7 @@ export class Bucket { }, () => { done.resolve(); + subscription.unsubscribe(); } ); await done.promise;