Repository navigation
feat(ios): implement fs push, pull, mkdir and rm on real devices #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicolasMazuryk
wants to merge
2
commits into
mobile-next:main
Choose a base branch
from
nicolasMazuryk:ios-real-device-fs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: mobile-next/mobilecli
Length of output: 7382
Script executed:
Repository: mobile-next/mobilecli
Length of output: 30557
Script executed:
Repository: mobile-next/mobilecli
Length of output: 29739
Web query:
github.com/danielpaulus/go-ios v1.0.211 afc WRITE_ONLY_CREATE_TRUNC Open truncates existing fileResult:
Do not truncate the final AFC destination before a push succeeds.
afcClientFS.OpenWriteopens the destination withafc.WRITE_ONLY_CREATE_TRUNC.afcPushthen copies directly to that path and reports copy, close, or size-check errors without rollback. A failed overwrite can therefore leave the pre-existing remote file empty or partially written.Stage the data in a temporary remote file, validate it, and atomically replace the destination. If the pinned AFC API cannot provide atomic replacement, reject overwrites instead of opening an existing destination in truncating mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid, fixed in e2099f9.
afcPushno longer truncates an existing destination before the new content is safely on the device..<name>.mobilecli-<hex>.tmp) and its size is verified. Only then is the old file removed and the content copied into place (size verified again), and the staging file removed. A failed or interrupted upload leaves the old file untouched and the staging file removed.Limitation: this is not atomic. go-ios (v1.0.211 pinned here, and v1.3.2) does not expose an AFC rename, so a rename-based swap is not possible without hand-rolling the AFC protocol. If the final copy fails, the partial destination is removed and the verified staging file is kept; the error names its path, so the new data is not lost. Only that narrow window can leave the old file gone. If go-ios gains a rename,
afcPushcan switch to it.Tests: new
TestAfcPushKeepsExistingDestinationcovers mid-way upload failure, size mismatch, successful overwrite without leftovers, failed final replacement, and a failed new-file write leaving no partial file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolasMazuryk Thanks for adding staging and failure-path tests. The supplied code confirms that
afcPushverifies the staging file before removing the existing destination.One part of the finding remains:
fs.Remove(remote)deletes the old content before the final copy succeeds. If that copy fails, the staging file preserves the new content, but the old content is lost. This improves upload safety, but it does not provide failed-overwrite preservation.To meet the original requirement without atomic replacement, reject overwrites before removing the existing destination. The thread should remain open for that remaining data-loss case.
You are interacting with an AI system.