Skip to content

Commit 0ec1897

Browse files
committed
download selected prefixes individually as zip
1 parent 1635f71 commit 0ec1897

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

portal-ui/src/screens/Console/ObjectBrowser/objectBrowserThunks.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,36 @@ export const downloadSelected = createAsyncThunk(
126126
const fileName = `${DateTime.now().toFormat(
127127
"LL-dd-yyyy-HH-mm-ss",
128128
)}_files_list.zip`;
129+
130+
const prefixesToDownload: BucketObjectItem[] = [];
129131
// We are enforcing zip download when multiple files are selected for better user experience
130132
const multiObjList = itemsToDownload.reduce((dwList: any[], bi) => {
131-
//Download only objects. Skip any prefixes, Del Markers selected before clicking download. and log for debugging
132-
if (bi && !bi?.name.endsWith("/") && !bi?.delete_flag) {
133+
// Download only objects as zip, and download each prefix individually as zip.
134+
// Skip any deleted files selected via "Show deleted objects" in selection and log for debugging
135+
const isPrefix = bi?.name.endsWith("/");
136+
const isDeleted = bi?.delete_flag;
137+
138+
if (bi && !isPrefix && !isDeleted) {
133139
dwList.push(bi.name);
134140
} else {
135-
console.log(`Skipping ${bi?.name} from download.`);
141+
if (isPrefix && !isDeleted) {
142+
prefixesToDownload.push(bi);
143+
} else {
144+
console.log(`Skipping ${bi?.name} from download.`);
145+
}
136146
}
137147
return dwList;
138148
}, []);
139149

150+
// Download selected objects as Zip.
140151
// can we batch with some limit like 100 or 1000 files at a time?
141152
await downloadSelectedAsZip(bucketName, multiObjList, fileName);
153+
// now begin download of each selected prefix as zip
154+
if (prefixesToDownload.length) {
155+
prefixesToDownload.forEach((prefix) => {
156+
downloadObject(prefix);
157+
});
158+
}
142159
return;
143160
}
144161
}

0 commit comments

Comments
 (0)