print errors if any

This commit is contained in:
Stefan Reitshamer 2011-11-21 17:06:55 -05:00
parent b2f65289c4
commit 056002c5b9
3 changed files with 18 additions and 2 deletions

View file

@ -238,6 +238,14 @@
return NO;
}
printf("restored files are in %s\n", [bucketName fileSystemRepresentation]);
NSDictionary *errorsByPath = [restorer errorsByPath];
if ([errorsByPath count] > 0) {
printf("Errors occurred:\n");
NSArray *sortedKeys = [[errorsByPath allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
for (NSString *key in sortedKeys) {
printf("%s\t\t%s\n", [key UTF8String], [[[errorsByPath objectForKey:key] localizedDescription] UTF8String]);
}
}
}
return YES;
}

View file

@ -56,4 +56,5 @@
}
- (id)initWithRepo:(ArqRepo *)theRepo bucketName:(NSString *)theBucketName commitSHA1:(NSString *)theCommitSHA1;
- (BOOL)restore:(NSError **)error;
- (NSDictionary *)errorsByPath;
@end

View file

@ -75,6 +75,7 @@
- (BOOL)createSymLink:(Node *)node path:(NSString *)symLinkFile target:(NSString *)target error:(NSError **)error;
- (BOOL)applyACLBlobKey:(BlobKey *)aclBlobKey uncompress:(BOOL)uncompress toPath:(NSString *)path error:(NSError **)error;
- (BOOL)applyXAttrsBlobKey:(BlobKey *)xattrsBlobKey uncompress:(BOOL)uncompress toFile:(NSString *)path error:(NSError **)error;
- (void)addError:(NSError *)theError forPath:(NSString *)thePath;
@end
@implementation Restorer
@ -154,6 +155,9 @@
}
return YES;
}
- (NSDictionary *)errorsByPath {
return errorsByPath;
}
@end
@implementation Restorer (internal)
@ -203,7 +207,7 @@
}
break;
}
[self performSelectorOnMainThread:@selector(addError:) withObject:[NSArray arrayWithObjects:restoreError, childPath, nil] waitUntilDone:YES];
[self addError:restoreError forPath:childPath];
}
} else {
NSError *restoreError = nil;
@ -216,7 +220,7 @@
break;
}
HSLogDebug(@"error restoring %@: %@", childPath, restoreError);
[self performSelectorOnMainThread:@selector(addError:) withObject:[NSArray arrayWithObjects:restoreError, childPath, nil] waitUntilDone:YES];
[self addError:restoreError forPath:childPath];
}
}
}
@ -690,4 +694,7 @@
}
return YES;
}
- (void)addError:(NSError *)theError forPath:(NSString *)thePath {
[errorsByPath setObject:theError forKey:thePath];
}
@end