shell_integration on OSX: Do not fill the cache with unsolicited statuses #3122
authorJocelyn Turcotte <jturcotte@woboq.com>
Wed, 6 May 2015 10:50:53 +0000 (12:50 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Wed, 6 May 2015 14:56:50 +0000 (16:56 +0200)
shell_integration/MacOSX/OwnCloudFinder/RequestManager.h
shell_integration/MacOSX/OwnCloudFinder/RequestManager.m

index 130c885c6c157e0c6c792e8a2fe312029a41f8a1..e5d4c19e119541031f10272891c66b7f2b85b354 100644 (file)
@@ -22,6 +22,7 @@
 
        NSMutableArray* _requestQueue;
        NSMutableDictionary* _registeredPathes;
+       NSMutableSet* _requestedPaths;
 
        NSString *_shareMenuTitle;
        
index 52f5d9f54ca23704e5a8829afd410d8939f5ad94..62399a441d6e9852805403cd2bba906145d52a77 100644 (file)
@@ -31,6 +31,7 @@ static RequestManager* sharedInstance = nil;
                _isConnected = NO;
 
                _registeredPathes = [[NSMutableDictionary alloc] init];
+               _requestedPaths = [[NSMutableSet alloc] init];
 
                _shareMenuTitle = nil;
 
@@ -106,6 +107,7 @@ static RequestManager* sharedInstance = nil;
        NSString *verb = @"RETRIEVE_FILE_STATUS";
 
        if( [self isRegisteredPath:path isDirectory:isDir] ) {
+               [_requestedPaths addObject:path];
                if( _isConnected ) {
                        if(isDir) {
                                verb = @"RETRIEVE_FOLDER_STATUS";
@@ -141,9 +143,13 @@ static RequestManager* sharedInstance = nil;
                                                        path, [chunks objectAtIndex:i+1] ];
                                }
                        }
-                       [contentman setResultForPath:path result:[chunks objectAtIndex:1]];
+                       // The client will broadcast all changes, do not fill the cache for paths that Finder didn't ask for.
+                       if ([_requestedPaths containsObject:path]) {
+                               [contentman setResultForPath:path result:[chunks objectAtIndex:1]];
+                       }
                } else if( [[chunks objectAtIndex:0] isEqualToString:@"UPDATE_VIEW"] ) {
                        NSString *path = [chunks objectAtIndex:1];
+                       [_requestedPaths removeAllObjects];
                        [contentman reFetchFileNameCacheForPath:path];
                } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
                        NSNumber *one = [NSNumber numberWithInt:1];
@@ -192,6 +198,7 @@ static RequestManager* sharedInstance = nil;
                for( NSString *path in _requestQueue ) {
                        [self askOnSocket:path query:@"RETRIEVE_FILE_STATUS"];
                }
+               [_requestQueue removeAllObjects];
        }
 
        ContentManager *contentman = [ContentManager sharedInstance];
@@ -212,6 +219,7 @@ static RequestManager* sharedInstance = nil;
        // clear the registered pathes.
        [_registeredPathes release];
        _registeredPathes = [[NSMutableDictionary alloc] init];
+       [_requestedPaths removeAllObjects];
 
     // clear the caches in conent manager
        ContentManager *contentman = [ContentManager sharedInstance];