Repository navigation
fix(downloads): delete downloads an administrator revoked - #673
Conversation
When the server reports revoked_removes_local, every registry read now
handles entries that come back revoked: it queues a durable delete
tombstone, hides the row, removes the media file, offline assets and
metadata row, and only then sends DELETE /api/v2/downloads/{id}. If the
local copy cannot be removed, the server entry stays and the next read
retries. Without the flag, behaviour is unchanged.
The Downloads tab re-reads saved downloads when a refresh elsewhere
removes one, and hides any download with a pending delete, so a revoked
copy is never offered for playback. An older queued transfer stops when
its registry row is revoked.
Refs Silo-Server#531
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
The revoked-download row disappearing from Downloads ( Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
| // Revoked entries were settled above, and only once their local copy is gone. | ||
| if (pending.recordId in revoked) continue |
There was a problem hiding this comment.
Premature server deletion occurs because revocation cleanup writes an ordinary deletion tombstone before removing local bytes, and scoped reconciliation skips it only while the current refresh includes pending.recordId in revoked; after local cleanup fails and the application restarts, a failed capability lookup causes removeRevokedEntries to return an empty set, allowing reconciliation to delete the server entry while the local file remains. Persist a local-cleanup-pending phase and block server-delete replay until local cleanup succeeds.
Prompt for LLM
File shared/src/commonMain/kotlin/org/siloserver/silo/repository/DownloadsRepository.kt:
Line 162 to 163:
Premature server deletion occurs because revocation cleanup writes an ordinary deletion tombstone before removing local bytes, and scoped reconciliation skips it only while the current refresh includes `pending.recordId` in `revoked`; after local cleanup fails and the application restarts, a failed capability lookup causes `removeRevokedEntries` to return an empty set, allowing reconciliation to delete the server entry while the local file remains. Persist a local-cleanup-pending phase and block server-delete replay until local cleanup succeeds.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Fixed in e85fc8d: when the capability cannot be read, revoked rows stay hidden and their tombstones are not replayed, so the server entry stays until a later read can clean up locally first. A new repository test covers the restart case (failed local delete, then a capability fetch that fails) and fails without the fix. When the capability is known, behaviour is unchanged.
There was a problem hiding this comment.
Based on your description, e85fc8d addresses the reported failure path: a failed capability lookup no longer permits tombstone replay before local cleanup succeeds, including after a restart.
The regression test covers the specific sequence raised in the suggestion. A persisted cleanup phase is not necessary for this scenario if the revised logic reliably blocks replay when the capability is unknown. I consider the original concern addressed as described; I haven’t independently inspected the commit.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Evidence is published at https://evidence.siloserver.org/r/silo-android/pr-673/: before and after on a Pixel 7, a Pixel Tablet and a Pixel Fold (open and folded). Android TV has no Downloads. |
Problem
Related issue: #531
Validation tasks: unblocks #329 C3
When an administrator revokes a download, the Android phone app keeps the copy. The server lists the entry as
revokedand reportsrevoked_removes_local: true, but the app keeps the file in shared storage, shows the row as "Ready", plays it, and never confirms the delete. The user manual says the app deletes revoked downloads the next time it connects, anddocs/downloads-api.md§9.3 in silo-server asks clients to do this.This change makes the app delete a revoked download's local copy and confirm the delete with the server. It covers only the revoked-entry half of #531; the
prepare_againhalf stays open there.Approach
DownloadsRepository.refreshchecks every registry read forrevokedentries, including reads from the background status worker and item detail. When the capability reportsrevoked_removes_local(fetched if not yet known), it writes the existing durable delete tombstone, hides the row, deletes the local copy, and only then sends theDELETE. If the local delete fails, the server entry is kept and the next read retries; the tombstone replay skips these entries, so the server never records a removal that did not happen.RevokedDownloadCleanupPortlets shared code ask the phone app to stop the transfer and delete the media file, offline assets and saved record under the slot lock. The TV app keeps no downloads and uses a no-op.The iOS app has the same gap; Silo-Server/silo-apple#716 tracks it and a separate pull request fixes it there.
Validation
./scripts/test-check-build-supply-chain.sh,./scripts/check-build-supply-chain.sh: pass../gradlew testDebugUnitTest: 908 tests, 1 failure,ReflowStyleTest > line height flows from settings, which also fails on main (confirmed on main at 5e19a58). New repository tests cover the flag check, cleanup beforeDELETE, the tombstone, and a failed local delete.:android-shared:lintDebug :androidApp:lintDebug :androidTvApp:lintDebug :androidApp:lintVitalRelease :androidTvApp:lintVitalRelease): pass.:androidApp:assembleDebugand:androidTvApp:assembleDebug: pass.revoked) and kept the file and the "Ready" row (twice on the phone, once on the tablet).DELETE(204) and removed the row; the server entry was gone. Repeated with a fresh download on the phone, and on the tablet.Evidence
Evidence: https://evidence.siloserver.org/r/silo-android/pr-673/
Surface and build: Pixel 7, Pixel Tablet and Pixel Fold emulators, Android 16. Before: main at 5e19a58. After: this branch. Each pair shows the Downloads tab after an administrator revoked the listed download.
Risks
A server that reports
revoked_removes_local: truenow causes the app to delete local files. Servers without the flag see no change. Deletion only follows an administrator's revoke and touches only that download's slot.Item detail's offline playback reads the saved record directly; if local deletion keeps failing, it could still offer that copy while the Downloads tab hides it.
Checklist
AI Disclosure