feat(boxstore): add configurable expiry for one-time downloads
Introduces a new configuration setting `one_time_download_expiry_seconds` to allow administrators to define a default expiration period for one-time downloads. The retention logic in `boxstore` has been updated to use this global expiry value when a box is marked as a one-time download and no specific retention period is defined in the manifest.
This commit is contained in:
@@ -211,8 +211,14 @@ func (app *App) handleOneTimeDownloadBox(ctx *gin.Context, boxID string) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if !hasManifest || !manifest.OneTimeDownload {
|
||||
ctx.String(http.StatusNotFound, "Box not found")
|
||||
if !hasManifest || !manifest.OneTimeDownload || manifest.Consumed {
|
||||
ctx.String(http.StatusGone, "Box already consumed")
|
||||
return
|
||||
}
|
||||
|
||||
manifest.Consumed = true
|
||||
if err := boxstore.WriteManifest(boxID, manifest); err != nil {
|
||||
ctx.String(http.StatusInternalServerError, "Could not mark box as consumed")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -327,7 +333,12 @@ func (app *App) handleDownloadThumbnail(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, _, authorized := app.authorizeBoxRequest(ctx, boxID, true); !authorized {
|
||||
manifest, hasManifest, authorized := app.authorizeBoxRequest(ctx, boxID, true)
|
||||
if !authorized {
|
||||
return
|
||||
}
|
||||
if hasManifest && manifest.OneTimeDownload {
|
||||
ctx.String(http.StatusForbidden, "Thumbnails disabled for one-time boxes")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user