Skip to content

fix(file-provider): Clean up stale chunked upload chunks - #10565

Open
claucambra wants to merge 21 commits into
masterfrom
work/chunk-cleanup-fpext
Open

fix(file-provider): Clean up stale chunked upload chunks#10565
claucambra wants to merge 21 commits into
masterfrom
work/chunk-cleanup-fpext

Conversation

@claucambra

Copy link
Copy Markdown
Collaborator

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)

@claucambra claucambra added this to the 35.0.0 milestone Aug 10, 2026
@claucambra
claucambra requested a balanced review from Copilot August 10, 2026 07:30
@claucambra claucambra self-assigned this Aug 10, 2026
@claucambra claucambra added os: 🍎 macOS Apple macOS, formerly also known as OS X feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. labels Aug 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +792 to +796
// 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(
Comment on lines +45 to +48
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
Comment on lines +31 to +36
discardChunkUploads(
forItemIdentifiers: chunkUploadOwnerIdentifiers,
usingRemoteInterface: remoteInterface,
dbManager: dbManager,
logger: logger
)
Comment on lines +83 to +87
logger.error(
"Could not remove local upload chunks.",
[.error: error, .name: uploadIdentifier]
)
return
@Rello Rello linked an issue Aug 15, 2026 that may be closed by this pull request
4 tasks
…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>
@claucambra
claucambra force-pushed the work/chunk-cleanup-fpext branch from 318e75a to f4be408 Compare August 15, 2026 14:40
@github-actions

Copy link
Copy Markdown
Contributor

Artifact containing the AppImage: nextcloud-appimage-pr-10565.zip

Digest: sha256:cda30316e76f5f08fbec8616c65cc56509d328f9171fe7d489b16d471df197d9

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.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. os: 🍎 macOS Apple macOS, formerly also known as OS X

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leftover files from transfers occupy disk

2 participants