Skip to content

Commit

Permalink
Fix delete when using root option in s3
Browse files Browse the repository at this point in the history
  • Loading branch information
rijkvanzanten committed Mar 12, 2021
1 parent 15d1317 commit 028cae4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/drive-s3/src/AmazonWebServicesS3Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '';
}

/**
Expand Down Expand Up @@ -263,6 +263,8 @@ export class AmazonWebServicesS3Storage extends Storage {
* Iterate over all files in the bucket.
*/
public async *flatList(prefix = ''): AsyncIterable<FileListResponse> {
prefix = this._fullPath(prefix);

let continuationToken: string | undefined;

do {
Expand All @@ -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) {
Expand Down

0 comments on commit 028cae4

Please sign in to comment.