-
Notifications
You must be signed in to change notification settings - Fork 69
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
Fail when installing big ipa file #4
Comments
Is the device locked when an error is reported? |
No, it will fail without the added d.lockdown = nil, whether locked or not. |
Was it an error at about Maybe I made a mistake here 👇 Line 158 in 8c797a4
Maybe that's right 👇
Can you give it a try? If it works as expected, PR welcomed 🥳 |
I changed all NewConnect() calls to include a 0 timeout. But it didn't work. |
🤔 Maybe |
Tried another method, sending a 'ping' message to lockdown service, and it worked.
|
You seem to have found another mistake I made I may not have written all the data correctly Can you try this? Will it still report an error? func (c *afc) WriteFile(filename string, data []byte, perm AfcFileMode) (err error) {
var file *AfcFile
if file, err = c.Open(filename, perm); err != nil {
return err
}
defer func() {
err = file.Close()
}()
if _, err = io.Copy(file, bytes.NewReader(data)); err != nil {
return err
}
return
} |
This still don't work. Actually the data was written correctly in my case.
Call stack:
There are 3 connections: a physical connection to usbmuxd, a tunneled connection to lockdown service, and a tunneled connection to afc service. The connection to installation service was never established. So we have to keep the connection alive, or reconnect when appropriate. |
Nice! I quite agree with you 👍
Maybe we have two ways to choose Looking forward to your PR func (d *device) AppInstall(ipaPath string) (err error) {
if _, err = d.AfcService(); err != nil {
return err
}
stagingPath := "PublicStaging"
if _, err = d.afc.Stat(stagingPath); err != nil {
if err != ErrAfcStatNotExist {
return err
}
if err = d.afc.Mkdir(stagingPath); err != nil {
return fmt.Errorf("app install: %w", err)
}
}
var info map[string]interface{}
if info, err = ipa.Info(ipaPath); err != nil {
return err
}
bundleID, ok := info["CFBundleIdentifier"]
if !ok {
return errors.New("can't find 'CFBundleIdentifier'")
}
installationPath := path.Join(stagingPath, fmt.Sprintf("%s.ipa", bundleID))
chUploaded := make(chan bool)
go func() {
for {
select {
case <-chUploaded:
return
default:
if _, err := newLockdown(d).QueryType(); err != nil {
debugLog(fmt.Sprintf("AppInstall 'ping': %s", err))
}
time.Sleep(time.Second * 5)
}
}
}()
var data []byte
if data, err = os.ReadFile(ipaPath); err != nil {
return err
}
if err = d.afc.WriteFile(installationPath, data, AfcFileModeWr); err != nil {
chUploaded <- true
return err
}
chUploaded <- true
if _, err = d.installationProxyService(); err != nil {
return err
}
return d.installationProxy.Install(fmt.Sprintf("%s", bundleID), installationPath)
}
func (d *device) lockdownService() (lockdown Lockdown, err error) {
if d.lockdown != nil {
return d.lockdown, nil
}
var innerConn InnerConn
if innerConn, err = d.NewConnect(LockdownPort, 0); err != nil {
return nil, err
}
d.lockdownClient = libimobiledevice.NewLockdownClient(innerConn)
d.lockdown = newLockdown(d)
_, err = d.lockdown._getProductVersion()
lockdown = d.lockdown
go func() {
for {
if _, err := lockdown.QueryType(); err != nil {
if strings.Contains(err.Error(), io.EOF.Error()) {
return
}
debugLog(fmt.Sprintf("lockdownService 'ping': %s", err))
}
time.Sleep(time.Second * 10)
}
}()
return
} |
When installing a big ipa file (3.3G), it will report error after uploading to PublicStaging:
device_test.go:104: receive packet: read tcp 127.0.0.1:15119->127.0.0.1:27015: wsarecv: An established connection was aborted by the software in your host machine.
It seems like lockdown connection has been closed by the phone.
A simple fix would work:
`
func (d *device) AppInstall(ipaPath string) (err error) {
if _, err = d.AfcService(); err != nil {
return err
}
}
`
Add a d.lockdown = nil before loading installation proxy service.
But I'm not sure that's the best way of fixing.
The text was updated successfully, but these errors were encountered: