Skip to content

Commit

Permalink
Ignore non-standard permissions in delta updates instead of failing t…
Browse files Browse the repository at this point in the history
…he build

Fixes #1383
  • Loading branch information
kornelski committed Mar 29, 2019
1 parent fc3221c commit 1edfcab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions Sparkle/SUBinaryDeltaCreate.m
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,10 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF

mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) {
permissions = 0755;
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Invalid file permissions after-tree on file %@ (only permissions with modes 0755 and 0644 are supported)", @(ent->fts_path)] }];
fprintf(stderr, "\nwarning: file permissions %o of '%s' won't be preserved in the delta update (only permissions with modes 0755 and 0644 are supported).\n", permissions & PERMISSION_FLAGS, ent->fts_path);
}
return NO;
}

if (aclExists(ent)) {
Expand Down Expand Up @@ -588,7 +585,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF

NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];

[filemgr removeItemAtPath: patchFile error: NULL];
if ([filemgr moveItemAtPath: temporaryFile toPath: patchFile error: NULL] != YES)
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/SUBinaryDeltaTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,10 @@ - (void)testInvalidPermissionsInAfterTree
XCTFail(@"Failed setting file permissions");
}

// This would fail for version 1.0
XCTAssertFalse([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]);
} afterDiffHandler:nil];
XCTAssertFalse(success);
// we just ignore bad permissions, since that's a too common problem to fail on
XCTAssertTrue(success);
}

- (void)testBadPermissionsInBeforeTree
Expand Down

0 comments on commit 1edfcab

Please sign in to comment.