Merge pull request #207 from ONLYOFFICE/bugfix/files-upload

Bugfix/files upload
This commit is contained in:
Alexey Safronov 2024-01-26 19:36:20 +04:00 committed by GitHub
commit be09767fb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -915,7 +915,8 @@ class UploadDataStore {
length,
resolve,
reject,
isAsyncUpload = false
isAsyncUpload = false,
isFinalize = false
) => {
if (!res.data.data && res.data.message) {
return reject(res.data.message);
@ -938,7 +939,11 @@ class UploadDataStore {
? fileSize
: this.settingsStore.chunkUploadSize;
} else {
uploadedSize = fileSize - index * this.settingsStore.chunkUploadSize;
uploadedSize = isFinalize
? 0
: fileSize <= this.settingsStore.chunkUploadSize
? fileSize
: fileSize - index * this.settingsStore.chunkUploadSize;
}
newPercent = this.getFilesPercent(uploadedSize);
}
@ -1041,18 +1046,17 @@ class UploadDataStore {
].chunksArray.findIndex((x) => !x.isActive && !x.isFinalize);
if (chunkObjIndex !== -1) {
this.asyncUploadObj[operationId].chunksArray[
chunkObjIndex
].isActive = true;
this.asyncUploadObj[operationId].chunksArray[chunkObjIndex].isActive =
true;
try {
const res = await this.asyncUploadObj[operationId].chunksArray[
chunkObjIndex
].onUpload();
const res =
await this.asyncUploadObj[operationId].chunksArray[
chunkObjIndex
].onUpload();
this.asyncUploadObj[operationId].chunksArray[
chunkObjIndex
].isFinished = true;
this.asyncUploadObj[operationId].chunksArray[chunkObjIndex].isFinished =
true;
if (!res.data.data && res.data.message) {
delete this.asyncUploadObj[operationId];
@ -1088,13 +1092,14 @@ class UploadDataStore {
].chunksArray.findIndex((x) => x.isFinalize);
if (finalizeChunkIndex > -1) {
const finalizeRes = await this.asyncUploadObj[
operationId
].chunksArray[finalizeChunkIndex].onUpload();
const finalizeIndex =
this.asyncUploadObj[operationId].chunksArray.length - 1;
const finalizeRes =
await this.asyncUploadObj[operationId].chunksArray[
finalizeChunkIndex
].onUpload();
this.checkChunkUpload(
t,
finalizeRes,
@ -1105,7 +1110,8 @@ class UploadDataStore {
length,
resolve,
reject,
true
true, // isAsyncUpload
true //isFinalize
);
}
}