Repository navigation
Make first remote uploads exclusive and recover safely - #35
Merged
Merged
Conversation
mikecerisano
force-pushed
the
fix/sftp-first-upload-20261017
branch
from
October 17, 2026 15:19
9740848 to
07608f3
Compare
mikecerisano
force-pushed
the
fix/sftp-first-upload-20261017
branch
from
October 17, 2026 15:19
07608f3 to
d8ece04
Compare
mikecerisano
marked this pull request as ready for review
October 17, 2026 15:20
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.
A first remote backup could fail before sending any file because
put -atried to resume a new UUID temporary path that did not yet exist. The first upload now claims a fresh remote file exclusively, streams the verified local backup into it, and publishes the final name without replacing an existing file. An interrupted upload is never presented as complete.The Mac provider sends a bundled Python 3 helper over SSH exec. The helper pins parent directory descriptors, refuses symlink leaves, creates the temporary file with exclusive/no-follow flags, reads it back when the chosen verification mode requires that, and publishes with a no-replace hard link. The app rehashes the exact opened local file descriptor against the manifest before sending bytes, bounds streamed input/output and command diagnostics, and keeps cancellation tied to the process-group runner merged in #36. Final upload-only status still says uploaded, not downloaded and checked; the SHA-256 mode downloads and checks remote bytes.
Recovery is deliberately conservative. A saved promotion intent only accepts an existing final when the retained temporary path and final are the same remote inode. A missing, swapped, or same-size unrelated object becomes a conflict or needs review. Interrupted uploads restart under a new UUID on explicit retry; uncertain old temporary paths are left untouched and identified privately to the operator. After a successful promotion, the hidden
.bitmatch-upload-UUIDname also remains as a hard link to the final file (the same inode, not a second copy of the bytes) for ownership proof and optional manual cleanup. BitMatch does not unlink an object that another writer may have replaced; queue and provider tests assert that pathname-only cleanup is not called.Supported-server requirements and limits:
openat/linkatsupport, and a remote destination filesystem that supports hard links for exclusive no-replace publication. Shell-less/SFTP-only accounts are unsupported by this path. Preflight checks the helper, but cannot prove a particular destination filesystem supports hard links; unsupported promotion fails closed when attempted.Local validation of the change:
sshdwith temporary keys, agent, pinned known-hosts, and remote root: helper adversarial probes passed; actual provider upload/readback 1/1 passed. This tests SSH exec on one local POSIX filesystem, not an external NAS or every server type.git diff --checkand helper syntax checks passed.The tested commit was rebased onto newer independent main changes with an identical stable patch ID and an equal
git range-diff; the full gates above were not rerun after that patch-identical base refresh. No release or external-server compatibility is claimed here.