Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: GEO-1007 s3 now reports deleted objects #841

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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