diff --git a/src/renderer/modules/qiniu-client/utils.ts b/src/renderer/modules/qiniu-client/utils.ts index 07a1d234..3e242207 100644 --- a/src/renderer/modules/qiniu-client/utils.ts +++ b/src/renderer/modules/qiniu-client/utils.ts @@ -97,14 +97,14 @@ export async function isAccelerateUploadingAvailable( user: AkItem, bucket: string, opt: GetAdapterOptionParam, - withoutCache = false, + refreshCache = false, ): Promise { if (user.specialType === AkSpecialType.STS) { return false; } return await getDefaultClient(opt).enter("isAccelerateUploadingAvailable", async client => { - if (withoutCache) { + if (refreshCache) { client.client.clearCache(); } const accUrls = await client.client.getServiceUrls({ diff --git a/src/renderer/pages/browse/files/index.tsx b/src/renderer/pages/browse/files/index.tsx index 5b5de078..6295965b 100644 --- a/src/renderer/pages/browse/files/index.tsx +++ b/src/renderer/pages/browse/files/index.tsx @@ -185,10 +185,10 @@ const Files: React.FC = (props) => { const [fetchingAccelerateUploading, setFetchingAccelerateUploading] = useState(false); const fetchAccelerateUploading = ({ needFeedback, - withoutCache, + refreshCache, }: { needFeedback?: boolean, - withoutCache?: boolean, + refreshCache?: boolean, } = {}) => { if (!currentUser || !props.bucket || fetchingAccelerateUploading) { return; @@ -203,7 +203,7 @@ const Files: React.FC = (props) => { currentUser, props.bucket?.name, opt, - withoutCache, + refreshCache, ); if (needFeedback) { p = toast.promise(p, { @@ -216,14 +216,11 @@ const Files: React.FC = (props) => { .catch(err => LocalLogger.error(err)) .finally(() => setFetchingAccelerateUploading(false)); }; - useEffect(() => { - fetchAccelerateUploading(); - }, [currentUser?.accessKey, props.bucket]); const refreshCanAccelerateUploading = () => { ipcUploadManager.clearRegionsCache(); fetchAccelerateUploading({ needFeedback: true, - withoutCache: true, + refreshCache: true, }); }; @@ -285,6 +282,15 @@ const Files: React.FC = (props) => { ] = useDisplayModal<{filePaths: string[]}>({ filePaths: [] }); + useEffect(() => { + if (!isShowUploadFilesConfirm) { + return; + } + ipcUploadManager.clearRegionsCache(); + fetchAccelerateUploading({ + refreshCache: true, + }); + }, [isShowUploadFilesConfirm]); // handle upload and download const handleUploadFiles = async (filePaths: string[]) => {