Skip to content

Fix sync uploads for new and missing chunked files - #28

Open
raphaeldelio wants to merge 1 commit into
redis:mainfrom
raphaeldelio:fix/sync-new-large-files
Open

Fix sync uploads for new and missing chunked files#28
raphaeldelio wants to merge 1 commit into
redis:mainfrom
raphaeldelio:fix/sync-new-large-files

Conversation

@raphaeldelio

@raphaeldelio raphaeldelio commented Sep 10, 2026

Copy link
Copy Markdown

Problem

A large file created after mounting an AFS sync volume could remain only on the local filesystem. Its upload failed with chunk meta <path>: redis: nil, so a new session could not restore it from Redis.

Files larger than 1 MiB use chunked uploads by default. Before uploading, AFS reads the remote chunk metadata. For a new file, Redis returns redis.Nil because that metadata does not exist yet. The uploader treated this as an error and stopped.

Solution

Treat the missing metadata as a file that needs to be created, then upload every local chunk.

Use the same approach when a previously synced remote file disappears. Sending only locally modified chunks would leave the unchanged parts missing from the recreated file. Existing remote files continue to receive only the changed chunks.

Validation

Regression tests verify complete uploads for a new large file and for a missing remote file with only one locally changed chunk. Both failures were reproduced before the fixes.

The full CLI test suite, make commands, and go vet ./cmd/afs passed.

This PR is independent of #29, which recovers missed watcher notifications. They can merge in either order.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant