Skip to content

Commit 2ca4a95

Browse files
committed
feat(OneDrive): show retry-after duration in error message if request is throttled, and mark such error as retryable.
1 parent 547078f commit 2ca4a95

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

public/locales/en-US/application.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@
298298
"chunkUploadError": "Failed to upload chunk [{{index}}].",
299299
"conflictError": "The upload task for files with the same name is already being processed.",
300300
"chunkUploadErrorWithMsg": "Chunk upload failed: {{msg}}",
301+
"chunkUploadErrorWithRetryAfter": "(Please retry after {{retryAfter}}s)",
301302
"emptyFileError": "Uploading empty files to OneDrive is not supported, please create empty files via the Create File button.",
302303
"finishUploadError": "Unable to complete file upload.",
303304
"finishUploadErrorWithMsg": "Unable to complete file upload: {{msg}}",

public/locales/zh-CN/application.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@
298298
"chunkUploadError": "分片 [{{index}}] 上传失败",
299299
"conflictError": "同名文件的上传任务已经在处理中",
300300
"chunkUploadErrorWithMsg": "分片上传失败: {{msg}}",
301+
"chunkUploadErrorWithRetryAfter": "(请在 {{retryAfter}} 秒后重试)",
301302
"emptyFileError": "暂不支持上传空文件至 OneDrive,请通过创建文件按钮创建空文件",
302303
"finishUploadError": "无法完成文件上传",
303304
"finishUploadErrorWithMsg": "无法完成文件上传: {{msg}}",

src/component/Uploader/core/errors/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,23 @@ export class OneDriveChunkError extends UploaderError {
228228
}
229229

230230
public Message(): string {
231-
return i18next.t(`uploader.chunkUploadErrorWithMsg`, {
231+
let msg = i18next.t(`uploader.chunkUploadErrorWithMsg`, {
232232
msg: this.message,
233233
});
234+
235+
if (this.response.error.retryAfterSeconds != undefined){
236+
msg += " "+i18next.t(`uploader.chunkUploadErrorWithRetryAfter`, {
237+
retryAfter: this.response.error.retryAfterSeconds,
238+
})
239+
}
240+
241+
return msg;
242+
}
243+
244+
public Retryable(): boolean {
245+
return (
246+
super.Retryable() || this.response.error.retryAfterSeconds != undefined
247+
);
234248
}
235249
}
236250

src/component/Uploader/core/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface OneDriveError {
7676
innererror?: {
7777
code: string;
7878
};
79+
retryAfterSeconds?: number;
7980
};
8081
}
8182

0 commit comments

Comments
 (0)