fix(core): update

This commit is contained in:
Philipp Kunz 2021-04-07 18:42:03 +00:00
parent 178c360b89
commit 476ff5bbce

View File

@ -50,7 +50,7 @@ export class Bucket {
/** /**
* store file * store file
*/ */
public async fastStore(pathArg: string, fileContent: string) { public async fastStore(pathArg: string, fileContent: string | Buffer): Promise<void> {
const streamIntake = new plugins.streamfunction.Intake(); const streamIntake = new plugins.streamfunction.Intake();
const putPromise = this.smartbucketRef.minioClient const putPromise = this.smartbucketRef.minioClient
.putObject(this.name, pathArg, streamIntake.getReadable()) .putObject(this.name, pathArg, streamIntake.getReadable())
@ -63,11 +63,11 @@ export class Bucket {
/** /**
* get file * get file
*/ */
public async fastGet(pathArg: string) { public async fastGet(pathArg: string): Promise<Buffer> {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
let completeFile: Buffer; let completeFile: Buffer;
const replaySubject = await this.fastGetStream(pathArg); const replaySubject = await this.fastGetStream(pathArg);
replaySubject.subscribe( const subscription = replaySubject.subscribe(
(chunk) => { (chunk) => {
if (completeFile) { if (completeFile) {
completeFile = Buffer.concat([completeFile, chunk]); completeFile = Buffer.concat([completeFile, chunk]);
@ -78,6 +78,7 @@ export class Bucket {
}, },
() => { () => {
done.resolve(); done.resolve();
subscription.unsubscribe();
} }
); );
await done.promise; await done.promise;