[Pkg-owncloud-commits] [owncloud-client] 07/175: shell_integration on OSX: Avoid too many RETRIEVE_FILE_STATUS following UPDATE_VIEW #3122

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 9ef8658122b7156657f9eba5cf3206d403f6258d
Author: Jocelyn Turcotte <jturcotte at woboq.com>
Date:   Wed May 6 12:54:18 2015 +0200

    shell_integration on OSX: Avoid too many RETRIEVE_FILE_STATUS following UPDATE_VIEW #3122
    
    Do not request the status of all entries in the cache. Instead force Finder
    to request the ones that it deems necessary by keeping the old statuses
    in a separate dictionary which are only used while the new status arrives.
---
 .../MacOSX/OwnCloudFinder/ContentManager.h         |  1 +
 .../MacOSX/OwnCloudFinder/ContentManager.m         | 32 ++++++++++++----------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h
index 31d26db..a3956ad 100644
--- a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h
+++ b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h
@@ -17,6 +17,7 @@
 @interface ContentManager : NSObject
 {
 	NSMutableDictionary* _fileNamesCache;
+	NSMutableDictionary* _oldFileNamesCache;
 	BOOL _fileIconsEnabled;
 	BOOL _hasChangedContent;
 	
diff --git a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m
index 941390d..5273205 100644
--- a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m
+++ b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m
@@ -30,6 +30,7 @@ static ContentManager* sharedInstance = nil;
 	if (self)
 	{
 		_fileNamesCache = [[NSMutableDictionary alloc] init];
+		_oldFileNamesCache = [[NSMutableDictionary alloc] init];
 		_fileIconsEnabled = TRUE;
 		_hasChangedContent = TRUE;
 	}
@@ -41,6 +42,7 @@ static ContentManager* sharedInstance = nil;
 {
 	[self removeAllIcons];
 	[_fileNamesCache release];
+	[_oldFileNamesCache release];
 	sharedInstance = nil;
 
 	[super dealloc];
@@ -153,6 +155,12 @@ static ContentManager* sharedInstance = nil;
 		// Set 0 into the cache, meaning "don't have an icon, but already requested it"
 		[_fileNamesCache setObject:result forKey:normalizedPath];
 	}
+	if ([result intValue] == 0) {
+		// Show the old state while we wait for the new one
+		NSNumber* oldResult = [_oldFileNamesCache objectForKey:normalizedPath];
+		if (oldResult)
+			result = oldResult;
+	}
 	// NSLog(@"iconByPath return value %d", [result intValue]);
 
 	return result;
@@ -163,32 +171,27 @@ static ContentManager* sharedInstance = nil;
 {
 	[_fileNamesCache release];
 	_fileNamesCache = [[NSMutableDictionary alloc] init];
+	[_oldFileNamesCache removeAllObjects];
 }
 
 - (void)reFetchFileNameCacheForPath:(NSString*)path
 {
-	 NSLog(@"%@", NSStringFromSelector(_cmd));
+	//NSLog(@"%@", NSStringFromSelector(_cmd));
 
-	for (id p in [_fileNamesCache keyEnumerator]) {
-		if ( path && [p hasPrefix:path] ) {
-			[[RequestManager sharedInstance] askForIcon:p isDirectory:false]; // FIXME isDirectory parameter
-			//[_fileNamesCache setObject:askState forKey:p]; We don't do this since we want to keep the old icon meanwhile
-			//NSLog(@"%@ %@", NSStringFromSelector(_cmd), p);
-		}
-	}
+	// We won't request the new state if if finds the path in _fileNamesCache
+	// Move all entries to _oldFileNamesCache so that the get re-requested, but
+	// still available while we refill the cache
+	[_oldFileNamesCache addEntriesFromDictionary:_fileNamesCache];
+	[_fileNamesCache removeAllObjects];
 
-	// Ask for directory itself
-	if ([path hasSuffix:@"/"]) {
-		path = [path substringToIndex:path.length - 1];
-	}
-	[[RequestManager sharedInstance] askForIcon:path isDirectory:true];
-	//NSLog(@"%@ %@", NSStringFromSelector(_cmd), path);
+	[self repaintAllWindows];
 }
 
 
 - (void)removeAllIcons
 {
 	[_fileNamesCache removeAllObjects];
+	[_oldFileNamesCache removeAllObjects];
 
 	[self repaintAllWindows];
 }
@@ -324,6 +327,7 @@ static ContentManager* sharedInstance = nil;
 		}
 		else
 		{
+			[_oldFileNamesCache removeObjectForKey:normalizedPath];
 			[_fileNamesCache setObject:iconId forKey:normalizedPath];
 		}
 	}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list