-
-
Notifications
You must be signed in to change notification settings - Fork 252
Refactor AFC #627
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
base: main
Are you sure you want to change the base?
Refactor AFC #627
Conversation
| return 0, fmt.Errorf("error reading data: %w", err) | ||
| } | ||
| resp, err := f.client.readPacket() | ||
| copy(p, resp.Payload) |
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.
| copy(p, resp.Payload) | |
| if err != nil { | |
| return 0, fmt.Errorf("error reading data: %w", err) | |
| } | |
| copy(p, resp.Payload) |
ios/afc/client.go
Outdated
| if err != nil { | ||
| break | ||
| } | ||
| if len(s) == 0 { |
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.
@dmissmann AFC directories may contain "." and "..". It may cause infinite recursion or traversing outside the subtree that was requested
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.
That was changed as you also did in the comment #627 (comment) the List method doesn't show those entries now and WalkDir won't see them when traversing the direcotry
ios/afc/client.go
Outdated
| if err != nil { | ||
| break | ||
| } | ||
| if len(s) == 0 { |
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.
| if len(s) == 0 { | |
| if len(s) <= 1 { |
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.
There's now a local variable that cuts off the NULL-terminator and we can check again for 0 (like in the example you posted below 😄 )
ios/afc/client.go
Outdated
| if len(s) == 0 { | ||
| continue | ||
| } | ||
| list = append(list, s[:len(s)-1]) |
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.
| list = append(list, s[:len(s)-1]) | |
| entry := s[:len(s)-1]) | |
| if entry == "." || entry == ".." { | |
| continue | |
| } | |
| list = append(list, s[:len(s)-1]) |
|
do I understand correctly that fsync --pull and --push only operate on single files now? instead of I think the pulling/pushing of directories may fail with AFC |
ios/house_arrest/house_arrest.go
Outdated
| c.deviceConn.Close() | ||
| func vendContainer(deviceConn ios.DeviceConnectionInterface, bundleID string) error { | ||
| plistCodec := ios.NewPlistCodec() | ||
| vendContainer := map[string]interface{}{"Command": "vendContainer", "Identifier": bundleID} |
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.
shouldn't it be "VendContainer"? I'm not sure renaming changes here anything, just to confirm :)
I reverted the changes in |
ios/afc/errors.go
Outdated
| case errDirNotEmpty: | ||
| return errors.New("DirNotEmpty") | ||
| default: | ||
| return nil |
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.
@dmissmann maybe we should return an error here?
return fmt.Errorf("unknown AFC error code: %d", errorCode)
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.
yep, thanks :)
The current implementation has a lot of repeated code. Every method that communicates with the afc service on the device has it's own logic for building the package and maintaining the package identifiers.
This is now done in a single place that abstracts away of this logic that was repeated over and over before.
Also, file I/O works now similar to "regular" filesystems. When we open a file using the afc service, we get back a
io.ReadWriteCloser, which allows us to use functions likeio.Copyon those files.