fix return error if chunk failed to upload

This commit is contained in:
Peter Maquiran
2024-02-15 23:18:51 +01:00
parent 8dd02b391f
commit 46fa354542
@@ -70,13 +70,23 @@ class UploadFileUseCase {
let connection = true let connection = true
let errorMessage: UploadError.noConnection | UploadError.slow let errorMessage: UploadError.noConnection | UploadError.slow
for (let index = 1; ( (index <= PublicationAttachmentEntity.chucksManager.chunks.totalChunks) ); index++) { for (let index = 1; ( (index <= PublicationAttachmentEntity.chucksManager.chunks.totalChunks) && connection ); index++) {
const needUpload = PublicationAttachmentEntity.chucksManager.needToUploadChunkIndex(index) const needUpload = PublicationAttachmentEntity.chucksManager.needToUploadChunkIndex(index)
if(needUpload) { if(needUpload) {
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
}
}
}) })
allRequest.push(request) allRequest.push(request)
} }