diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index a643fba1..21b3f57a 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -103,6 +103,7 @@ NS_ASSUME_NONNULL_BEGIN * If the owner and group IDs match on the root items of targetURL and matchURL, this method stops and assumes that nothing needs to be done. * Otherwise this method recursively changes the IDs if the target is a directory. If an item in the directory is encountered that is unable to be changed, * then this method stops and returns NO. + * While this method will try to change the group ID, being unable to change the group ID does not result in a failure if the owner ID can be changed or matched. * * This is not an atomic operation. */ diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 5b8e09d7..b81af0f4 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -434,15 +434,30 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) { // Speeds up the common case return YES; } - - if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:groupID error:error]) { - return NO; + + // If we can't change both the new owner & group, try to only change the owner + // If this works, this is sufficient enough for performing the update + NSNumber *groupIDToUse; + if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:groupID error:NULL]) { + if ((targetOwnerID != nil && [ownerID isEqualToNumber:targetOwnerID])) { + // Assume they're the same even if we don't check every file recursively + // Speeds up the common case like above + return YES; + } + + if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:targetGroupID error:error]) { + return NO; + } + + groupIDToUse = targetGroupID; + } else { + groupIDToUse = groupID; } if (isTargetADirectory) { NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; for (NSURL *url in directoryEnumerator) { - if (![self _changeOwnerAndGroupOfItemAtURL:url ownerID:ownerID groupID:groupID error:error]) { + if (![self _changeOwnerAndGroupOfItemAtURL:url ownerID:ownerID groupID:groupIDToUse error:error]) { return NO; } }