Skip to content

Commit eaf9bd7

Browse files
committed
iterate on checkS3Object functionality
1 parent 6c58891 commit eaf9bd7

File tree

1 file changed

+11
-34
lines changed

1 file changed

+11
-34
lines changed

src/s3.ts

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -358,48 +358,25 @@ export const checkS3Object = async (
358358
root: string,
359359
path?: string
360360
): Promise<void> => {
361+
console.log(path, root);
361362
// checking the existance of an S3 object
362363
if (path) {
363-
try {
364-
await s3Client.send(
365-
new HeadObjectCommand({
366-
Bucket: bucketName,
367-
Key: PathExt.join(root, path)
368-
})
369-
);
370-
} catch {
371-
Promise.reject();
372-
}
373-
} else {
374-
// checking if the root folder exists
375-
const rootInfo = await s3Client.send(
364+
await s3Client.send(
365+
new HeadObjectCommand({
366+
Bucket: bucketName,
367+
Key: PathExt.join(root, path)
368+
})
369+
);
370+
}
371+
// checking if the root folder exists
372+
else {
373+
await s3Client.send(
376374
new ListObjectsV2Command({
377375
Bucket: bucketName,
378376
Prefix: root + '/'
379377
})
380378
);
381-
382-
if (rootInfo.Contents!.length > 0) {
383-
Promise.resolve();
384-
} else {
385-
Promise.reject();
386-
}
387379
}
388-
// try {
389-
// await s3Client.send(
390-
// new HeadObjectCommand({
391-
// Bucket: bucketName,
392-
// Key: path ? PathExt.join(root, path) : root + '/' // check whether we are looking at an object or the root
393-
// })
394-
// );
395-
// } catch (error) {
396-
// await s3Client.send(
397-
// new HeadObjectCommand({
398-
// Bucket: bucketName,
399-
// Key: path ? PathExt.join(root, path) : root + '/.emptyFolderPlaceholder' // check whether we are looking at an object or the root
400-
// })
401-
// );
402-
// }
403380
};
404381

405382
/**

0 commit comments

Comments
 (0)