Merge pull request #7432 from nextcloud/bugfix/findersyncext-crash-pt3000

Fix crash when setting badge for a path that results in a nil URL (macOS FinderSyncExt)
This commit is contained in:
Matthieu Gallien 2024-11-19 14:08:38 +01:00 committed by GitHub
commit c1f9861265
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -194,10 +194,14 @@
#pragma mark - SyncClientProxyDelegate implementation #pragma mark - SyncClientProxyDelegate implementation
- (void)setResultForPath:(NSString*)path result:(NSString*)result - (void)setResult:(NSString *)result forPath:(NSString*)path
{ {
NSString *normalizedPath = [path decomposedStringWithCanonicalMapping]; NSString *const normalizedPath = path.decomposedStringWithCanonicalMapping;
[[FIFinderSyncController defaultController] setBadgeIdentifier:result forURL:[NSURL fileURLWithPath:normalizedPath]]; NSURL *const urlForPath = [NSURL fileURLWithPath:normalizedPath];
if (urlForPath == nil) {
return;
}
[FIFinderSyncController.defaultController setBadgeIdentifier:result forURL:urlForPath];
} }
- (void)reFetchFileNameCacheForPath:(NSString*)path - (void)reFetchFileNameCacheForPath:(NSString*)path

View file

@ -42,7 +42,7 @@
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Setting result %@ for path %@", result, path); NSLog(@"Setting result %@ for path %@", result, path);
[self.delegate setResultForPath:path result:result]; [self.delegate setResult:result forPath:path];
}); });
} else if([command isEqualToString:@"UPDATE_VIEW"]) { } else if([command isEqualToString:@"UPDATE_VIEW"]) {
NSString *path = [split objectAtIndex:1]; NSString *path = [split objectAtIndex:1];

View file

@ -15,7 +15,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@protocol SyncClientDelegate <NSObject> @protocol SyncClientDelegate <NSObject>
- (void)setResultForPath:(NSString *)path result:(NSString *)result; - (void)setResult:(NSString *)result forPath:(NSString *)path;
- (void)reFetchFileNameCacheForPath:(NSString *)path; - (void)reFetchFileNameCacheForPath:(NSString *)path;
- (void)registerPath:(NSString *)path; - (void)registerPath:(NSString *)path;
- (void)unregisterPath:(NSString *)path; - (void)unregisterPath:(NSString *)path;