Implement remote attachment blob cleanup queue for sync - #77
Open
patrickunterwegs wants to merge 1 commit into
Open
Implement remote attachment blob cleanup queue for sync#77patrickunterwegs wants to merge 1 commit into
patrickunterwegs wants to merge 1 commit into
Conversation
The app could upload attachment blobs but never delete them: removing an attachment, deleting an entry, or moving one to another calendar all left the uploaded file behind in its CalDAV collection (and local files behind on the device), so storage grew without bound. Adds a proper cleanup lifecycle: - New WebDAV deleteFile(url) primitive. - New PendingRemoteDeletionDto table (schema migration 13) that queues orphaned blob URLs independently of entries, so the ON DELETE CASCADE from an entry can't lose them before they're deleted. - SyncCoordinator drains the queue per calendar after pushing local changes, best-effort with retry (2xx or 404 clears the entry, anything else retries). Enqueue points: - Attachment removal (details screen) queues the removed blob. - Move queues the source-collection blobs - captured before re-creating the entries, since the copy's attachment rows reuse the same UNIQUE uid and replace the originals'. Only blobs that get re-uploaded into the target are queued; a remote-only attachment the copy still points at is left alone. - Trashbin hard-delete (deleteTrashed) queues each attachment's blob and deletes its local file before the rows cascade away. IcalEntryRepositoryImpl now depends on FileManager to reclaim local files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XuDzYDVnD3s5Zzm7aJ3K3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a persistent queue mechanism to track and clean up orphaned attachment blobs from CalDAV servers. When attachments are removed, entries are deleted, or entries are moved between calendars, their remote blobs are now queued for deletion and cleaned up during the next sync cycle.
Key Changes
New
PendingRemoteFileDeletiondomain model: Represents a remote attachment blob queued for deletion with its calendar context and remote URL.Database schema additions:
PendingRemoteDeletionDtotable to persist the deletion queue independently of entry lifecycle (survives entry cascading deletes)13.sqmand SQL queries inpending_remote_deletion_dto.sqfor queue managementRepository enhancements (
IcalEntryRepositoryImpl):FileManagerdependency for local file cleanupenqueueRemoteFileDeletions(),getPendingRemoteFileDeletions(),deletePendingRemoteFileDeletion()moveIcalEntries()to queue source collection blobs for deletion before re-creating entries in target calendardeleteTrashed()to queue remote blobs and delete local files before hard-deleting entriesSync engine integration (
SyncCoordinator):drainPendingRemoteFileDeletions()method called after each sync cycleWebDAV remote data source:
deleteFile()method to perform HTTP DELETE on attachment blob URLsRemoteDataSourceIcalEntry.ktviadeleteFileMultiplatform()UI integration (
DetailsViewModel):Implementation Details
IcalEntryDtoto survive entry cascading deletesINSERT OR IGNOREto handle duplicate URLs gracefullyhttps://claude.ai/code/session_011XuDzYDVnD3s5Zzm7aJ3K3