Browse Source

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
Klaas Freitag 11 years ago
parent
commit
688b8dcc38

+ 2 - 2
shell_integration/MacOSX/OwnCloudFinder/ContentManager.m

@@ -139,7 +139,7 @@ static ContentManager* sharedInstance = nil;
 	}
 	NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
 
-	if (![[RequestManager sharedInstance] isRegisteredPath:normalizedPath]) {
+	if (![[RequestManager sharedInstance] isRegisteredPath:normalizedPath isDirectory:isDir]) {
 		return [NSNumber numberWithInt:0];
 	}
 	
@@ -192,7 +192,7 @@ static ContentManager* sharedInstance = nil;
 
 - (void)reFetchFileNameCacheForPath:(NSString*)path
 {
-	NSLog(@"%@", NSStringFromSelector(_cmd));
+	// NSLog(@"%@", NSStringFromSelector(_cmd));
 
 	for (id p in [_fileNamesCache keyEnumerator]) {
 		if ( path && [p hasPrefix:path] ) {

+ 1 - 1
shell_integration/MacOSX/OwnCloudFinder/RequestManager.h

@@ -31,7 +31,7 @@
 
 + (RequestManager*)sharedInstance;
 
-- (BOOL)isRegisteredPath:(NSString*)path;
+- (BOOL)isRegisteredPath:(NSString*)path isDirectory:(BOOL)isDir;
 - (void)askOnSocket:(NSString*)path query:(NSString*)verb;
 - (NSNumber*)askForIcon:(NSString*)path isDirectory:(BOOL)isDir;
 - (void)menuItemClicked:(NSDictionary*)actionDictionary;

+ 10 - 4
shell_integration/MacOSX/OwnCloudFinder/RequestManager.m

@@ -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
 	NSArray *regPathes = [_registeredPathes allKeys];
 	BOOL registered = NO;
 
+	NSString* checkPath = [[NSString alloc] initWithString:path];
+	if (isDir) {
+		// append a slash
+		checkPath = [path stringByAppendingString:@"/"];
+	}
+
 	for( NSString *regPath in regPathes ) {
-		if( [path hasPrefix:regPath]) {
+		if( [checkPath hasPrefix:regPath]) {
 			// the path was registered
 			registered = YES;
 			break;
@@ -99,7 +105,7 @@ static RequestManager* sharedInstance = nil;
 	NSString *verb = @"RETRIEVE_FILE_STATUS";
 	NSNumber *res = [NSNumber numberWithInt:0];
 
-	if( [self isRegisteredPath:path] ) {
+	if( [self isRegisteredPath:path isDirectory:isDir] ) {
 		if( _isConnected ) {
 			if(isDir) {
 				verb = @"RETRIEVE_FOLDER_STATUS";
@@ -140,11 +146,11 @@ static RequestManager* sharedInstance = nil;
 		} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
 			NSNumber *one = [NSNumber numberWithInt:1];
 			NSString *path = [chunks objectAtIndex:1];
+			NSLog(@"Registering path: %@", path);
 			[_registeredPathes setObject:one forKey:path];
 			
 			[contentman repaintAllWindows];
 		} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"UNREGISTER_PATH"] ) {
-			NSNumber *one = [NSNumber numberWithInt:1];
 			NSString *path = [chunks objectAtIndex:1];
 			[_registeredPathes removeObjectForKey:path];