From 36816814011ab4b9d7788891790d0b4c2a75637b Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Mon, 22 Apr 2024 16:27:31 +0800 Subject: [PATCH] :bug: Fix(custom): fix aws s3 urlprefix bug --- package.json | 2 +- src/main/utils/deleteFunc.ts | 23 +++++++++++++++++------ src/renderer/manage/pages/bucketPage.vue | 5 ++--- yarn.lock | 8 ++++---- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 60d71b2..e69d3d9 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "multer": "^1.4.5-lts.1", "node-ssh-no-cpu-features": "^1.0.1", "nodejs-file-downloader": "^4.12.1", - "piclist": "^1.8.5", + "piclist": "^1.8.6", "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.0", "proxy-agent": "^5.0.0", diff --git a/src/main/utils/deleteFunc.ts b/src/main/utils/deleteFunc.ts index c808ab9..648a205 100644 --- a/src/main/utils/deleteFunc.ts +++ b/src/main/utils/deleteFunc.ts @@ -134,12 +134,23 @@ export async function removeFileFromS3InMain (configMap: IStringKeyMap, dogeMode sessionToken: configMap.config.sessionToken } } - const client = new S3Client(s3Options) - const command = new DeleteObjectCommand({ - Bucket: bucketName, - Key: fileKey - }) - const result = await client.send(command) + let result: any + try { + const client = new S3Client(s3Options) + const command = new DeleteObjectCommand({ + Bucket: bucketName, + Key: fileKey + }) + result = await client.send(command) + } catch (err: any) { + s3Options.region = 'us-east-1' + const client = new S3Client(s3Options) + const command = new DeleteObjectCommand({ + Bucket: bucketName, + Key: fileKey + }) + result = await client.send(command) + } return result.$metadata.httpStatusCode === 204 } catch (err: any) { console.log(err) diff --git a/src/renderer/manage/pages/bucketPage.vue b/src/renderer/manage/pages/bucketPage.vue index ab59ff6..a08fbf9 100644 --- a/src/renderer/manage/pages/bucketPage.vue +++ b/src/renderer/manage/pages/bucketPage.vue @@ -2832,9 +2832,8 @@ async function getBucketFileListBackStage () { isLoadingData.value = true const fileTransferStore = useFileTransferStore() fileTransferStore.resetFileTransferList() - if (currentPicBedName.value === 'webdavplist' || - currentPicBedName.value === 'local' || - currentPicBedName.value === 'sftp') { + const picBedNamesArr = ['webdavplist', 'local', 'sftp'] + if (picBedNamesArr.includes(currentPicBedName.value)) { param.baseDir = configMap.baseDir param.webPath = configMap.webPath } diff --git a/yarn.lock b/yarn.lock index 92dec1b..356aa48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12397,10 +12397,10 @@ performance-now@^2.1.0: resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== -piclist@^1.8.5: - version "1.8.5" - resolved "https://registry.yarnpkg.com/piclist/-/piclist-1.8.5.tgz#982f481420c83cb42d6c1ff07bd2ad467ed71539" - integrity sha512-RrSWViLbgTb3VeZ5Poajo6oyRbpFovF3g48/JiyMG6XChdt7BZ1dD/URmPzfrQNZM+bwunSwJr1yjhK87cSvwA== +piclist@^1.8.6: + version "1.8.6" + resolved "https://registry.yarnpkg.com/piclist/-/piclist-1.8.6.tgz#858706b5628953926ce0777d4a287482c2ebee10" + integrity sha512-ja/bUCifnoI/J2zTI79Kkuao4rdm64ZL6kqUFcZ2aSHQULLsFMkgDPiPPvVN5wF8Sv7mX9z4fVmj6UVM7r5uQQ== dependencies: "@aws-sdk/client-s3" "3.421.0" "@aws-sdk/lib-storage" "3.421.0"