Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJocelyn Turcotte <jturcotte@woboq.com>2015-05-06 13:54:18 +0300
committerJocelyn Turcotte <jturcotte@woboq.com>2015-05-06 17:56:50 +0300
commit9ef8658122b7156657f9eba5cf3206d403f6258d (patch)
tree422b3ec656f65e7db68cfbd66be4a4b9f6c84d47 /shell_integration/MacOSX
parent0a67719f2fce9d46bf009755fd1b1759c57bb4c4 (diff)
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.
Diffstat (limited to 'shell_integration/MacOSX')
-rw-r--r--shell_integration/MacOSX/OwnCloudFinder/ContentManager.h1
-rw-r--r--shell_integration/MacOSX/OwnCloudFinder/ContentManager.m32
2 files changed, 19 insertions, 14 deletions
diff --git a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h
index 31d26dbf2..a3956adc4 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 941390ded..527320573 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];
}
}