Skip to content

Commit

Permalink
fix: GEO-1007 s3 now reports deleted objects (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
jer3k authored Nov 6, 2024
1 parent c3c353c commit 61307fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/src/external/services/s3-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const deleteFiles = async (ids: string[]): Promise<Set<string>> => {
try {
// Get all the files stored under each id
const filesPerId = await Promise.all(
ids.map((id) => getFileList(s3Client, id)), //TODO: try deleting the folders instead of each individual file. https://stackoverflow.com/a/73367823
ids.map((id) => getFileList(s3Client, id)),
);
const idsWithNoFiles = ids.filter(
(id, index) => filesPerId[index].length === 0,
Expand All @@ -150,15 +150,15 @@ export const deleteFiles = async (ids: string[]): Promise<Set<string>> => {

// report any errors
responsePerGroup.forEach((r) =>
r.Errors.forEach((e) => {
r.Errors?.forEach((e) => {
if (e.Code == 'NoSuchKey') idsWithNoFiles.push(getIdFromKey(e.Key));
logger.error(e.Message);
}),
);

// Return the id of all successful deleted
const successfulIds = responsePerGroup.flatMap((r) =>
r.Deleted.reduce((acc, x) => {
r.Deleted?.reduce((acc, x) => {
acc.push(getIdFromKey(x.Key));
return acc;
}, [] as string[]),
Expand Down

0 comments on commit 61307fb

Please sign in to comment.