diff --git a/package.json b/package.json index c3457175..e70e0c72 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "form-data": "^4.0.0", "js-base64": "^3.4.5", "js-md5": "^0.7.3", - "kodo-s3-adapter-sdk": "0.7.0", + "kodo-s3-adapter-sdk": "0.7.1", "lockfile": "^1.0.4", "lodash": "^4.17.21", "mime": "^2.3.1", diff --git a/src/common/ipc-actions/download.ts b/src/common/ipc-actions/download.ts index 321ee589..29a42a1a 100644 --- a/src/common/ipc-actions/download.ts +++ b/src/common/ipc-actions/download.ts @@ -1,5 +1,5 @@ import {NatureLanguage} from "kodo-s3-adapter-sdk/dist/uplog"; -import {Domain} from "kodo-s3-adapter-sdk/dist/adapter"; +import {Domain, UrlStyle} from "kodo-s3-adapter-sdk/dist/adapter"; import {ClientOptionsSerialized} from "@common/qiniu"; import {Status} from "@common/models/job/types"; @@ -24,6 +24,7 @@ export interface DownloadOptions { bucket: string, domain?: Domain, + urlStyle?: UrlStyle, isOverwrite: boolean, storageClasses: StorageClass[], diff --git a/src/common/models/job/download-job.ts b/src/common/models/job/download-job.ts index 1ef32552..be5b2b70 100644 --- a/src/common/models/job/download-job.ts +++ b/src/common/models/job/download-job.ts @@ -3,7 +3,7 @@ import fs, {constants as fsConstants, promises as fsPromises} from "fs"; import lodash from "lodash"; import {Downloader} from "kodo-s3-adapter-sdk"; -import {Adapter, Domain, ObjectHeader, StorageClass} from "kodo-s3-adapter-sdk/dist/adapter"; +import {Adapter, Domain, ObjectHeader, StorageClass, UrlStyle} from "kodo-s3-adapter-sdk/dist/adapter"; import {NatureLanguage} from "kodo-s3-adapter-sdk/dist/uplog"; import {ClientOptions, createQiniuClient} from "@common/qiniu"; @@ -36,7 +36,8 @@ interface DownloadOptions { interface OptionalOptions extends DownloadOptions { id: string, - domain?: Domain, + domain: Domain | undefined, + urlStyle: UrlStyle | undefined, status: Status, message: string, @@ -58,6 +59,8 @@ type Options = RequiredOptions & Partial const DEFAULT_OPTIONS: OptionalOptions = { id: "", + domain: undefined, + urlStyle: undefined, multipartDownloadThreshold: 100, multipartDownloadSize: 8, @@ -86,6 +89,7 @@ type PersistInfo = { from: RequiredOptions["from"], backendMode: RequiredOptions["clientOptions"]["backendMode"], domain: OptionalOptions["domain"], + urlStyle: OptionalOptions["urlStyle"], prog: OptionalOptions["prog"], status: Exclude, message: OptionalOptions["message"], @@ -112,6 +116,8 @@ export default class DownloadJob extends TransferJob { ): DownloadJob { return new DownloadJob({ id, + domain: persistInfo.domain, + urlStyle: persistInfo.urlStyle, status: persistInfo.status, message: persistInfo.message, @@ -213,6 +219,7 @@ export default class DownloadJob extends TransferJob { to: this.options.to, from: this.options.from, domain: this.options.domain, + urlStyle: this.options.urlStyle, storageClasses: this.options.storageClasses, backendMode: this.options.clientOptions.backendMode, @@ -297,6 +304,7 @@ export default class DownloadJob extends TransferJob { this.tempFilePath, this.options.domain, { + urlStyle: this.options.urlStyle, recoveredFrom: this.prog.resumable ? this.prog.loaded : 0, diff --git a/src/main/transfer-managers/download-manager.ts b/src/main/transfer-managers/download-manager.ts index 7bf67f86..f0c0e355 100644 --- a/src/main/transfer-managers/download-manager.ts +++ b/src/main/transfer-managers/download-manager.ts @@ -293,6 +293,7 @@ export default class DownloadManager extends TransferManager = ({ useEffect(() => { reset({ - storageClassKodoName: availableStorageClasses[0].kodoName ?? "Standard", + storageClassKodoName: availableStorageClasses[0]?.kodoName ?? "", }); }, []); @@ -97,33 +96,37 @@ const ChangeStorageClassForm: React.FC = ({ } - - - {translate("forms.changeStorageClass.storageClassKodoName.label")} - -
- { - availableStorageClasses.map(storageClass => ( - - )) - } - - { - availableStorageClasses - .find(storageClasses => - storageClasses.kodoName === watch("storageClassKodoName")) - ?.billingI18n[currentLanguage] - } - -
-
+ { + !availableStorageClasses.length + ? null + : + + {translate("forms.changeStorageClass.storageClassKodoName.label")} + +
+ { + availableStorageClasses.map(storageClass => ( + + )) + } + + { + availableStorageClasses + .find(storageClasses => + storageClasses.kodoName === watch("storageClassKodoName")) + ?.billingI18n[currentLanguage] + } + +
+
+ } ); diff --git a/src/renderer/components/modals/file/change-file-storage-class/index.tsx b/src/renderer/components/modals/file/change-file-storage-class/index.tsx index 82f3353d..f9bdd734 100644 --- a/src/renderer/components/modals/file/change-file-storage-class/index.tsx +++ b/src/renderer/components/modals/file/change-file-storage-class/index.tsx @@ -58,11 +58,12 @@ const ChangeFileStorageClass: React.FC const changeStorageClassFormController = useForm({ mode: "onChange", defaultValues: { - storageClassKodoName: storageClasses[0]?.kodoName ?? "Standard", + storageClassKodoName: storageClasses[0]?.kodoName ?? "", }, }); const { + watch, handleSubmit, formState: { isSubmitting, @@ -135,7 +136,7 @@ const ChangeFileStorageClass: React.FC { - !memoFileItem || isSubmitSuccessful + !memoFileItem || !watch("storageClassKodoName") || isSubmitSuccessful ? null :