mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
MacOverlays: Pass isDir flag to isRegisteredPath method
With that, a path can be added to directories to also detect the sync top directory. This fixes bug #2053
This commit is contained in:
parent
280edee1db
commit
688b8dcc38
3 changed files with 13 additions and 7 deletions
|
@ -139,7 +139,7 @@ static ContentManager* sharedInstance = nil;
|
||||||
}
|
}
|
||||||
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
|
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
|
||||||
|
|
||||||
if (![[RequestManager sharedInstance] isRegisteredPath:normalizedPath]) {
|
if (![[RequestManager sharedInstance] isRegisteredPath:normalizedPath isDirectory:isDir]) {
|
||||||
return [NSNumber numberWithInt:0];
|
return [NSNumber numberWithInt:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ static ContentManager* sharedInstance = nil;
|
||||||
|
|
||||||
- (void)reFetchFileNameCacheForPath:(NSString*)path
|
- (void)reFetchFileNameCacheForPath:(NSString*)path
|
||||||
{
|
{
|
||||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
// NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||||
|
|
||||||
for (id p in [_fileNamesCache keyEnumerator]) {
|
for (id p in [_fileNamesCache keyEnumerator]) {
|
||||||
if ( path && [p hasPrefix:path] ) {
|
if ( path && [p hasPrefix:path] ) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
+ (RequestManager*)sharedInstance;
|
+ (RequestManager*)sharedInstance;
|
||||||
|
|
||||||
- (BOOL)isRegisteredPath:(NSString*)path;
|
- (BOOL)isRegisteredPath:(NSString*)path isDirectory:(BOOL)isDir;
|
||||||
- (void)askOnSocket:(NSString*)path query:(NSString*)verb;
|
- (void)askOnSocket:(NSString*)path query:(NSString*)verb;
|
||||||
- (NSNumber*)askForIcon:(NSString*)path isDirectory:(BOOL)isDir;
|
- (NSNumber*)askForIcon:(NSString*)path isDirectory:(BOOL)isDir;
|
||||||
- (void)menuItemClicked:(NSDictionary*)actionDictionary;
|
- (void)menuItemClicked:(NSDictionary*)actionDictionary;
|
||||||
|
|
|
@ -77,14 +77,20 @@ static RequestManager* sharedInstance = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)isRegisteredPath:(NSString*)path
|
- (BOOL)isRegisteredPath:(NSString*)path isDirectory:(BOOL)isDir
|
||||||
{
|
{
|
||||||
// check if the file in question is underneath a registered directory
|
// check if the file in question is underneath a registered directory
|
||||||
NSArray *regPathes = [_registeredPathes allKeys];
|
NSArray *regPathes = [_registeredPathes allKeys];
|
||||||
BOOL registered = NO;
|
BOOL registered = NO;
|
||||||
|
|
||||||
|
NSString* checkPath = [[NSString alloc] initWithString:path];
|
||||||
|
if (isDir) {
|
||||||
|
// append a slash
|
||||||
|
checkPath = [path stringByAppendingString:@"/"];
|
||||||
|
}
|
||||||
|
|
||||||
for( NSString *regPath in regPathes ) {
|
for( NSString *regPath in regPathes ) {
|
||||||
if( [path hasPrefix:regPath]) {
|
if( [checkPath hasPrefix:regPath]) {
|
||||||
// the path was registered
|
// the path was registered
|
||||||
registered = YES;
|
registered = YES;
|
||||||
break;
|
break;
|
||||||
|
@ -99,7 +105,7 @@ static RequestManager* sharedInstance = nil;
|
||||||
NSString *verb = @"RETRIEVE_FILE_STATUS";
|
NSString *verb = @"RETRIEVE_FILE_STATUS";
|
||||||
NSNumber *res = [NSNumber numberWithInt:0];
|
NSNumber *res = [NSNumber numberWithInt:0];
|
||||||
|
|
||||||
if( [self isRegisteredPath:path] ) {
|
if( [self isRegisteredPath:path isDirectory:isDir] ) {
|
||||||
if( _isConnected ) {
|
if( _isConnected ) {
|
||||||
if(isDir) {
|
if(isDir) {
|
||||||
verb = @"RETRIEVE_FOLDER_STATUS";
|
verb = @"RETRIEVE_FOLDER_STATUS";
|
||||||
|
@ -140,11 +146,11 @@ static RequestManager* sharedInstance = nil;
|
||||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
|
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
|
||||||
NSNumber *one = [NSNumber numberWithInt:1];
|
NSNumber *one = [NSNumber numberWithInt:1];
|
||||||
NSString *path = [chunks objectAtIndex:1];
|
NSString *path = [chunks objectAtIndex:1];
|
||||||
|
NSLog(@"Registering path: %@", path);
|
||||||
[_registeredPathes setObject:one forKey:path];
|
[_registeredPathes setObject:one forKey:path];
|
||||||
|
|
||||||
[contentman repaintAllWindows];
|
[contentman repaintAllWindows];
|
||||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"UNREGISTER_PATH"] ) {
|
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"UNREGISTER_PATH"] ) {
|
||||||
NSNumber *one = [NSNumber numberWithInt:1];
|
|
||||||
NSString *path = [chunks objectAtIndex:1];
|
NSString *path = [chunks objectAtIndex:1];
|
||||||
[_registeredPathes removeObjectForKey:path];
|
[_registeredPathes removeObjectForKey:path];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue