Skip to content

Commit 3e470b1

Browse files
Eugene Nikolskyeunikolsky
authored andcommitted
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 4c91455 commit 3e470b1

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
@@ -160,6 +160,20 @@
160160
} \
161161
} while (false);
162162

163+
// Checks for MobileDevice.framework errors and tries to print them.
164+
#define log_error(call) \
165+
do { \
166+
unsigned int err = (unsigned int)call; \
167+
if (err != 0) \
168+
{ \
169+
const char* msg = get_error_message(err); \
170+
NSString *description = msg ? [NSString stringWithUTF8String:msg] : @"unknown."; \
171+
NSLogJSON(@{@"Event": @"Error", @"Code": @(err), @"Status": description}); \
172+
log_on_error(@"Error 0x%x: %@ " #call, err, description); \
173+
} \
174+
} while (false);
175+
176+
163177

164178
void disable_ssl(ServiceConnRef con)
165179
{
@@ -175,6 +189,18 @@ void disable_ssl(ServiceConnRef con)
175189
con->sslContext = NULL;
176190
}
177191

192+
void log_on_error(NSString* format, ...)
193+
{
194+
va_list valist;
195+
va_start(valist, format);
196+
NSString* str = [[[NSString alloc] initWithFormat:format arguments:valist] autorelease];
197+
va_end(valist);
198+
199+
if (!_json_output) {
200+
NSLog(@"[ !! ] %@", str);
201+
}
202+
}
203+
178204

179205
void on_error(NSString* format, ...)
180206
{
@@ -2060,7 +2086,7 @@ void rmtree_callback(AFCConnectionRef conn, const char *name, read_dir_cb_reason
20602086
{
20612087
if (reason == READ_DIR_FILE || reason == READ_DIR_AFTER_DIR) {
20622088
NSLogVerbose(@"Deleting %s", name);
2063-
check_error(AFCRemovePath(conn, name));
2089+
log_error(AFCRemovePath(conn, name));
20642090
} else if (reason == READ_DIR_FIFO) {
20652091
NSLogVerbose(@"Skipping %s", name);
20662092
}

0 commit comments

Comments
 (0)