fix(file-provider): Clean up stale chunked upload chunks - #10565
fix(file-provider): Clean up stale chunked upload chunks#10565claucambra wants to merge 21 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds lifecycle management for local chunked-upload files and bookkeeping.
Changes:
- Cleans chunks after uploads, deletions, and extension startup.
- Extends remote interfaces to expose and remove chunk directories.
- Adds regression tests and lifecycle documentation.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
UploadTests.swift |
Tests upload cleanup and resume behavior. |
ItemModifyTests.swift |
Tests metadata retention after failures. |
ItemDeleteTests.swift |
Tests cleanup during deletion. |
ChunkUploadCleanupTests.swift |
Tests startup cleanup policies. |
MockRemoteInterfaceTests.swift |
Tests mock chunk storage. |
MockRemoteInterface.swift |
Simulates chunk files and removal. |
TestableRemoteInterface.swift |
Updates protocol test implementation. |
Upload.swift |
Integrates upload cleanup lifecycle. |
ChunkUploadCleanup.swift |
Adds cleanup and bookkeeping helpers. |
Item+Modify.swift |
Preserves or clears upload identifiers. |
Item+Delete.swift |
Cleans uploads after deletion. |
RemoteInterface.swift |
Extends the chunk-upload contract. |
NextcloudKit+RemoteInterface.swift |
Implements local chunk removal. |
FileProviderExtension.swift |
Runs cleanup during startup. |
Documentation.md |
Links the new design note. |
ChunkedUploads.md |
Documents chunk lifecycle behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // TODO: Initial file creation does not persist item metadata until the upload succeeds. | ||
| // Running cleanup during setup therefore removes its remaining chunks after an extension | ||
| // restart, before File Provider can resume the create. Persist pending-create metadata, | ||
| // or otherwise distinguish pending local creations from abandoned uploads, first. | ||
| cleanupAbandonedChunkUploads( |
| let legacyPrefix = chunkUploadIdentifierPrefix(forItemWithIdentifier: itemIdentifier) | ||
| let chunkIdentifiers = db.objects(RemoteFileChunk.self) | ||
| .where { $0.remoteChunkStoreFolderName.starts(with: legacyPrefix) } | ||
| .map(\.remoteChunkStoreFolderName) |
| newMetadata.sessionTaskIdentifier = 0 | ||
| newMetadata.downloaded = true | ||
| newMetadata.uploaded = true | ||
| newMetadata.chunkUploadId = nil |
| discardChunkUploads( | ||
| forItemIdentifiers: chunkUploadOwnerIdentifiers, | ||
| usingRemoteInterface: remoteInterface, | ||
| dbManager: dbManager, | ||
| logger: logger | ||
| ) |
| logger.error( | ||
| "Could not remove local upload chunks.", | ||
| [.error: error, .name: uploadIdentifier] | ||
| ) | ||
| return |
…location Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…upload Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…ock remote interface Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com> f RI Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
… records Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…ifier Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…r onto a itemmetadata Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…cation failure Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…interface Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…ions correctly Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
318e75a to
f4be408
Compare
|
Artifact containing the AppImage: nextcloud-appimage-pr-10565.zip Digest: To test this change/fix you can download the above artifact file, unzip it, and run it. Please make sure to quit your existing Nextcloud app and backup your data. |
|



Summary
Chunked upload chunks can stick around after upload attempts, filling up local storage. This PR adds various cleanup procedures to prevent this from happening
Checklist
AI (if applicable)