From ebd62b1581cc96eb9244a3876a8c7aa8f8759a24 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Mon, 18 Apr 2022 00:56:25 +0800 Subject: [PATCH] new s3 every request to avoid request expired --- src/remote.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/remote.ts b/src/remote.ts index 050587f..0173419 100644 --- a/src/remote.ts +++ b/src/remote.ts @@ -15,7 +15,6 @@ import { log } from "./moreOnLog"; export class RemoteClient { readonly serviceType: SUPPORTED_SERVICES_TYPE; - readonly s3Client?: s3.S3Client; readonly s3Config?: S3Config; readonly webdavClient?: webdav.WrappedWebdavClient; readonly webdavConfig?: WebdavConfig; @@ -38,7 +37,6 @@ export class RemoteClient { // so we use a ref not copy of config here if (serviceType === "s3") { this.s3Config = s3Config; - this.s3Client = s3.getS3Client(this.s3Config); } else if (serviceType === "webdav") { if (vaultName === undefined || saveUpdatedConfigFunc === undefined) { throw Error( @@ -86,7 +84,7 @@ export class RemoteClient { getRemoteMeta = async (fileOrFolderPath: string) => { if (this.serviceType === "s3") { return await s3.getRemoteMeta( - this.s3Client, + s3.getS3Client(this.s3Config), this.s3Config, fileOrFolderPath ); @@ -116,7 +114,7 @@ export class RemoteClient { ) => { if (this.serviceType === "s3") { return await s3.uploadToRemote( - this.s3Client, + s3.getS3Client(this.s3Config), this.s3Config, fileOrFolderPath, vault, @@ -168,7 +166,11 @@ export class RemoteClient { listFromRemote = async (prefix?: string) => { if (this.serviceType === "s3") { - return await s3.listFromRemote(this.s3Client, this.s3Config, prefix); + return await s3.listFromRemote( + s3.getS3Client(this.s3Config), + this.s3Config, + prefix + ); } else if (this.serviceType === "webdav") { return await webdav.listFromRemote(this.webdavClient, prefix); } else if (this.serviceType === "dropbox") { @@ -190,7 +192,7 @@ export class RemoteClient { ) => { if (this.serviceType === "s3") { return await s3.downloadFromRemote( - this.s3Client, + s3.getS3Client(this.s3Config), this.s3Config, fileOrFolderPath, vault, @@ -241,7 +243,7 @@ export class RemoteClient { ) => { if (this.serviceType === "s3") { return await s3.deleteFromRemote( - this.s3Client, + s3.getS3Client(this.s3Config), this.s3Config, fileOrFolderPath, password, @@ -276,7 +278,7 @@ export class RemoteClient { checkConnectivity = async (callbackFunc?: any) => { if (this.serviceType === "s3") { return await s3.checkConnectivity( - this.s3Client, + s3.getS3Client(this.s3Config), this.s3Config, callbackFunc );