From 7d31198348587ad48818ee5a948720ab26d7a8fb Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 23 Feb 2024 13:17:45 +0100 Subject: [PATCH] change upload to paralel --- .../upload/upload-streaming.service.ts | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/app/shared/publication/upload/upload-streaming.service.ts b/src/app/shared/publication/upload/upload-streaming.service.ts index 555741778..8f8053d7b 100644 --- a/src/app/shared/publication/upload/upload-streaming.service.ts +++ b/src/app/shared/publication/upload/upload-streaming.service.ts @@ -76,34 +76,34 @@ class UploadFileUseCase { if(needUpload) { // upload every chunk at onces - // const request = readAndUploadChunk(index).then(async(uploadRequest) => { + const request = readAndUploadChunk(index).then(async(uploadRequest) => { - // if(uploadRequest.isErr()) { - // connection = false - // const pingRequest = await this.CMAPIService.ping() - // if( pingRequest.isErr()) { - // errorMessage = UploadError.noConnection - // } else { - // errorMessage = UploadError.slow - // } - // } + if(uploadRequest.isErr()) { + connection = false + const pingRequest = await this.CMAPIService.ping() + if( pingRequest.isErr()) { + errorMessage = UploadError.noConnection + } else { + errorMessage = UploadError.slow + } + } - // }) - // allRequest.push(request) + }) + allRequest.push(request) // one by one chunk upload - const request = readAndUploadChunk(index) - allRequest.push(request) - const uploadRequest = await request + // const request = readAndUploadChunk(index) + // allRequest.push(request) + // const uploadRequest = await request - if(uploadRequest.isErr()) { - const pingRequest = await this.CMAPIService.ping() - if( pingRequest.isErr()) { - return resolve(err(UploadError.noConnection)) - } else { - return resolve(err(UploadError.slow)) - } - } + // if(uploadRequest.isErr()) { + // const pingRequest = await this.CMAPIService.ping() + // if( pingRequest.isErr()) { + // return resolve(err(UploadError.noConnection)) + // } else { + // return resolve(err(UploadError.slow)) + // } + // } } } @@ -269,14 +269,17 @@ export class PublicationFormMV { PublicationAttachmentEntity.chucksManager.setManualRetry() resolve(false) } else { - const guid = PublicationAttachmentEntity.chucksManager.path - this.ObjectMergeNotification.subscribe(guid, (data) => { + + PublicationAttachmentEntity.chucksManager.doneChunkUpload() + const mergeRequest = await this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path) + + if(mergeRequest.isOk()) { PublicationAttachmentEntity.chucksManager.contentSetReady() resolve(true) - }) - PublicationAttachmentEntity.chucksManager.doneChunkUpload() - this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path) - resolve(true) + } else { + resolve(false) + } + } } else {