mirror of
https://github.com/sparkle-project/Sparkle.git
synced 2025-11-01 15:34:38 +00:00
Fix removeTree not working for symbolic links and added tests
I accidently broke this a few commits ago where I inserted a return value for it
This commit is contained in:
Vendored
+5
-1
@@ -195,7 +195,11 @@ extern NSString *hashOfTree(NSString *path)
|
||||
BOOL removeTree(NSString *path)
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
return ![fileManager fileExistsAtPath:path] ? YES : [fileManager removeItemAtPath:path error:nil];
|
||||
// Don't use fileExistsForPath: because it will try to follow symbolic links
|
||||
if (![fileManager attributesOfItemAtPath:path error:nil]) {
|
||||
return YES;
|
||||
}
|
||||
return [fileManager removeItemAtPath:path error:nil];
|
||||
}
|
||||
|
||||
BOOL copyTree(NSString *source, NSString *dest)
|
||||
|
||||
@@ -434,6 +434,36 @@ typedef void (^SUDeltaHandler)(NSFileManager *fileManager, NSString *sourceDirec
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testRemovingSymlink
|
||||
{
|
||||
[self createAndApplyPatchWithHandler:^(NSFileManager *fileManager, NSString *sourceDirectory, NSString *destinationDirectory) {
|
||||
NSString *sourceFile = [sourceDirectory stringByAppendingPathComponent:@"A"];
|
||||
|
||||
NSError *error = nil;
|
||||
if (![fileManager createSymbolicLinkAtPath:sourceFile withDestinationPath:@"B" error:&error]) {
|
||||
NSLog(@"Error in creating symlink: %@", error);
|
||||
XCTFail(@"Failed to create symlink");
|
||||
}
|
||||
|
||||
XCTAssertFalse([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testAddingSymlink
|
||||
{
|
||||
[self createAndApplyPatchWithHandler:^(NSFileManager *fileManager, NSString *sourceDirectory, NSString *destinationDirectory) {
|
||||
NSString *destinationFile = [destinationDirectory stringByAppendingPathComponent:@"A"];
|
||||
|
||||
NSError *error = nil;
|
||||
if (![fileManager createSymbolicLinkAtPath:destinationFile withDestinationPath:@"B" error:&error]) {
|
||||
NSLog(@"Error in creating symlink: %@", error);
|
||||
XCTFail(@"Failed to create symlink");
|
||||
}
|
||||
|
||||
XCTAssertFalse([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testSmallFilePermissionChangeWithNoContentChange
|
||||
{
|
||||
[self createAndApplyPatchWithHandler:^(NSFileManager *fileManager, NSString *sourceDirectory, NSString *destinationDirectory) {
|
||||
|
||||
Reference in New Issue
Block a user