Skip to content

Commit

Permalink
fix(cloud-storage): cancel upload when error (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Apr 1, 2021
1 parent 58698f0 commit 54f201e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion desktop/renderer-app/src/pages/CloudStoragePage/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ export class CloudStorageStore extends CloudStorageStoreBase {

onUploadPanelClose = (): void => {
if (Array.from(this.uploadStatusesMap.values()).some(this.isUploadNotFinished)) {
message.warning("there are tasks not finished");
Modal.confirm({
title: "取消上传",
content: "上传尚未完成,确定取消所有正在进行的上传吗?",
cancelText: "再想想",
onOk: () => {
this.clearUploadStatusesMap();
},
});
} else {
this.clearUploadStatusesMap();
}
Expand Down
3 changes: 3 additions & 0 deletions desktop/renderer-app/src/pages/CloudStoragePage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ class UploadManager {
this._tasks.add(currentTask);
this._upload(file, currentTask)
.catch(error => {
if (!isFakeID(currentTask.fileUUID)) {
cancelUpload({ fileUUIDs: [currentTask.fileUUID] });
}
if (error instanceof Axios.Cancel) {
currentTask.onCancel?.();
} else {
Expand Down

0 comments on commit 54f201e

Please sign in to comment.