Skip to content

Commit 458908e

Browse files
authored
fix: getFiles filter prefix leading slash (#304)
1 parent 1de7924 commit 458908e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/s3/controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ export class S3Service {
385385
};
386386

387387
public async getFiles(prefix: string): Promise<string[]> {
388+
if (prefix.startsWith('/')) {
389+
prefix = prefix.slice(1);
390+
}
388391
const objectNames: string[] = [];
389392
const stream = this.client.listObjectsV2(this.config.bucket, prefix, true);
390393

@@ -431,7 +434,9 @@ export class S3Service {
431434

432435
public async moveFiles(srcPath: string, distPath: string): Promise<void> {
433436
try {
434-
// Normalize paths to ensure they end with '/'
437+
if (srcPath.startsWith('/')) {
438+
srcPath = srcPath.slice(1);
439+
}
435440
const normalizedSrcPath = srcPath.endsWith('/') ? srcPath : `${srcPath}/`;
436441
const normalizedDistPath = distPath.endsWith('/') ? distPath : `${distPath}/`;
437442

0 commit comments

Comments
 (0)