diff --git a/src/ios-deploy/ios-deploy.m b/src/ios-deploy/ios-deploy.m index 41f0b933..22e21ecc 100644 --- a/src/ios-deploy/ios-deploy.m +++ b/src/ios-deploy/ios-deploy.m @@ -1175,7 +1175,7 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) { on_error(@"Failed to open %s", custom_script_path); } fwrite("\n", 1, 1, out); - char buffer[0x1000]; + char buffer[262144]; // 256KB buffer for faster transfers size_t bytesRead; while ((bytesRead = fread(buffer, 1, sizeof(buffer), fh)) > 0) { @@ -1244,7 +1244,7 @@ void server_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef ServiceConnRef dbgServiceConnection = (ServiceConnRef)CFDictionaryGetValue(connection_properties, kDbgConnectionPropertyServiceConnection); CFSocketRef lldb_socket = (CFSocketRef)CFDictionaryGetValue(connection_properties, kDbgConnectionPropertyLLDBSocket); - char buffer[0x1000]; + char buffer[262144]; // 256KB buffer for faster transfers int bytesRead; do { bytesRead = AMDServiceConnectionReceive(dbgServiceConnection, buffer, sizeof(buffer)); @@ -2171,6 +2171,31 @@ void copy_file_callback(AFCConnectionRef afc_conn_p, const char *name, read_dir_ if (*local_name=='\0') return; if (reason == READ_DIR_FILE || reason == READ_DIR_FIFO) { + // Get remote file size using AFCFileInfoOpen + struct afc_dictionary *afc_dict_p = NULL; + long long remote_size = -1; + + unsigned int code = AFCFileInfoOpen(afc_conn_p, name, &afc_dict_p); + if (code == 0) { + char *key, *val; + while((AFCKeyValueRead(afc_dict_p, &key, &val) == 0) && key && val) { + if (strcmp(key, "st_size") == 0) { + remote_size = atoll(val); + break; + } + } + AFCKeyValueClose(afc_dict_p); + } + + // Check if local file exists and has the same size + struct stat local_stat; + if (remote_size >= 0 && stat(local_name, &local_stat) == 0) { + if (local_stat.st_size == remote_size) { + NSLogOut(@"%@ (skipped - already downloaded)", [NSString stringWithUTF8String:name]); + return; + } + } + NSLogOut(@"%@", [NSString stringWithUTF8String:name]); afc_file_ref fref; int err = AFCFileRefOpen(afc_conn_p,name,1,&fref); @@ -2188,7 +2213,7 @@ void copy_file_callback(AFCConnectionRef afc_conn_p, const char *name, read_dir_ return; } - char buf[4096]; + char buf[262144]; // 256KB buffer for faster transfers size_t sz=sizeof(buf); while (AFCFileRefRead(afc_conn_p,fref,buf,&sz)==0 && sz) {