From 028cae4771656d75a901a0ae943f63a5653df2bb Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Fri, 12 Mar 2021 16:29:18 -0500 Subject: [PATCH] Fix delete when using root option in s3 Fixes #4460 --- packages/drive-s3/src/AmazonWebServicesS3Storage.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/drive-s3/src/AmazonWebServicesS3Storage.ts b/packages/drive-s3/src/AmazonWebServicesS3Storage.ts index 6837891370266..f26cf95541997 100644 --- a/packages/drive-s3/src/AmazonWebServicesS3Storage.ts +++ b/packages/drive-s3/src/AmazonWebServicesS3Storage.ts @@ -47,7 +47,7 @@ export class AmazonWebServicesS3Storage extends Storage { }); this.$bucket = config.bucket; - this.$root = config.root ?? ''; + this.$root = config.root ? path.normalize(config.root) : ''; } /** @@ -263,6 +263,8 @@ export class AmazonWebServicesS3Storage extends Storage { * Iterate over all files in the bucket. */ public async *flatList(prefix = ''): AsyncIterable { + prefix = this._fullPath(prefix); + let continuationToken: string | undefined; do { @@ -279,9 +281,11 @@ export class AmazonWebServicesS3Storage extends Storage { continuationToken = response.NextContinuationToken; for (const file of response.Contents as ObjectList) { + const path = file.Key as string; + yield { raw: file, - path: file.Key as string, + path: path.substring(this.$root.length), }; } } catch (e) {