Skip to content

Commit 0676ee0

Browse files
committed
Continue removing files after an error
The fix is to skip removing FIFOs had a side-effect of failing to remove a directory where a skipped file is because the directory is not empty. The change here is to continue removing files after errors, which is also helpful in cases when `ios-deploy` fails to remove `/Documents/` ("Error 0xa: You do not have permission."), but still needs to continue removing what it can from `/Library/`.
1 parent c6cb47d commit 0676ee0

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/ios-deploy/ios-deploy.m

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@
148148
} \
149149
} while (false);
150150

151+
// Checks for MobileDevice.framework errors and tries to print them.
152+
#define log_error(call) \
153+
do { \
154+
unsigned int err = (unsigned int)call; \
155+
if (err != 0) \
156+
{ \
157+
const char* msg = get_error_message(err); \
158+
NSString *description = msg ? [NSString stringWithUTF8String:msg] : @"unknown."; \
159+
NSLogJSON(@{@"Event": @"Error", @"Code": @(err), @"Status": description}); \
160+
log_on_error(@"Error 0x%x: %@ " #call, err, description); \
161+
} \
162+
} while (false);
163+
164+
151165

152166
void disable_ssl(ServiceConnRef con)
153167
{
@@ -163,6 +177,18 @@ void disable_ssl(ServiceConnRef con)
163177
con->sslContext = NULL;
164178
}
165179

180+
void log_on_error(NSString* format, ...)
181+
{
182+
va_list valist;
183+
va_start(valist, format);
184+
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
185+
va_end(valist);
186+
187+
if (!_json_output) {
188+
NSLog(@"[ !! ] %@", str);
189+
}
190+
}
191+
166192

167193
void on_error(NSString* format, ...)
168194
{
@@ -2037,7 +2063,7 @@ void rmtree_callback(AFCConnectionRef conn, const char *name, read_dir_cb_reason
20372063
{
20382064
if (reason == READ_DIR_FILE || reason == READ_DIR_AFTER_DIR) {
20392065
NSLogVerbose(@"Deleting %s", name);
2040-
check_error(AFCRemovePath(conn, name));
2066+
log_error(AFCRemovePath(conn, name));
20412067
} else if (reason == READ_DIR_FIFO) {
20422068
NSLogVerbose(@"Skipping %s", name);
20432069
}

0 commit comments

Comments
 (0)