From 1edfcaba71d07a0a3b1b3df654bcd58e33794503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Thu, 28 Mar 2019 23:48:31 +0000 Subject: [PATCH] Ignore non-standard permissions in delta updates instead of failing the build Fixes #1383 --- Sparkle/SUBinaryDeltaCreate.m | 9 +++------ Tests/SUBinaryDeltaTest.m | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index 7ee037e428..44e2d50113 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -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)) { @@ -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) { diff --git a/Tests/SUBinaryDeltaTest.m b/Tests/SUBinaryDeltaTest.m index 7c95b37ae4..1a906adef9 100644 --- a/Tests/SUBinaryDeltaTest.m +++ b/Tests/SUBinaryDeltaTest.m @@ -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