feat(boxstore): add one-time download retention mode
Introduce a `one-time` retention option and persist it on the manifest as `one_time_download`. One-time download boxes bypass retention expiry scheduling, force zip downloads, and reject download attempts until all files are complete to prevent partial retrievals.feat(boxstore): add one-time download retention mode Introduce a `one-time` retention option and persist it on the manifest as `one_time_download`. One-time download boxes bypass retention expiry scheduling, force zip downloads, and reject download attempts until all files are complete to prevent partial retrievals.
This commit is contained in:
@@ -14,6 +14,7 @@ const retentionSelect = document.querySelector("#upload-retention");
|
||||
const passwordEnabled = document.querySelector("#upload-password-enabled");
|
||||
const passwordInput = document.querySelector("#upload-password");
|
||||
const zipEnabled = document.querySelector("#upload-zip-enabled");
|
||||
const oneTimeRetentionKey = "one-time";
|
||||
|
||||
let selectedFiles = [];
|
||||
let statusTimer = null;
|
||||
@@ -118,6 +119,24 @@ function setBoxStatus(message) {
|
||||
}
|
||||
}
|
||||
|
||||
function isOneTimeDownloadSelected() {
|
||||
return retentionSelect && retentionSelect.value === oneTimeRetentionKey;
|
||||
}
|
||||
|
||||
function updateZipOptionForRetention() {
|
||||
if (!zipEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOneTimeDownloadSelected()) {
|
||||
zipEnabled.checked = true;
|
||||
zipEnabled.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
zipEnabled.disabled = false;
|
||||
}
|
||||
|
||||
function setBoxLink(path) {
|
||||
shareURL = path ? new URL(path, window.location.origin).toString() : "";
|
||||
|
||||
@@ -257,7 +276,7 @@ async function createBox() {
|
||||
body: JSON.stringify({
|
||||
retention_key: retentionSelect ? retentionSelect.value : "10s",
|
||||
password: passwordEnabled && passwordEnabled.checked && passwordInput ? passwordInput.value : "",
|
||||
allow_zip: !zipEnabled || zipEnabled.checked,
|
||||
allow_zip: isOneTimeDownloadSelected() || !zipEnabled || zipEnabled.checked,
|
||||
files: selectedFiles.map((selectedFile) => ({
|
||||
name: selectedFile.file.name,
|
||||
size: selectedFile.file.size,
|
||||
@@ -383,6 +402,11 @@ if (passwordEnabled && passwordInput) {
|
||||
});
|
||||
}
|
||||
|
||||
if (retentionSelect) {
|
||||
updateZipOptionForRetention();
|
||||
retentionSelect.addEventListener("change", updateZipOptionForRetention);
|
||||
}
|
||||
|
||||
if (fileInput && dropzone) {
|
||||
dropzone.addEventListener("dragover", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const boxPanel = document.querySelector(".box-panel[data-box-id]");
|
||||
const boxStatus = document.querySelector(".box-statusbar span:first-child");
|
||||
const zipOnly = boxPanel && boxPanel.dataset.zipOnly === "true";
|
||||
|
||||
document.querySelectorAll('.box-file[aria-disabled="true"]').forEach((item) => {
|
||||
item.addEventListener("click", (event) => {
|
||||
@@ -27,7 +28,7 @@ function updateBoxFile(file) {
|
||||
item.dataset.status = file.status;
|
||||
item.title = file.title;
|
||||
|
||||
if (isComplete) {
|
||||
if (isComplete && !zipOnly) {
|
||||
item.href = file.download_path;
|
||||
item.setAttribute("download", "");
|
||||
item.removeAttribute("aria-disabled");
|
||||
|
||||
Reference in New Issue
Block a user