Skip to content

Conversation

@icewind1991
Copy link
Member

For most external storages getting the storage info is expense

Since the storage info doesn't change often we cache it for 5 min

comparison when using fed. share

Signed-off-by: Robin Appelman <[email protected]>
@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Jan 23, 2017
@icewind1991 icewind1991 added this to the Nextcloud 12.0 milestone Jan 23, 2017
@mention-bot
Copy link

@icewind1991, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MorrisJobke, @blizzz and @nickvergessen to be potential reviewers.

@MorrisJobke
Copy link
Member

Does that also mean that when you are uploading still the old storage info is used and you maybe could upload more than allowed?

@icewind1991
Copy link
Member Author

Free space is still checked on upload

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works 👍

*/
public static function getStorageInfo($path, $rootInfo = null) {
$memcache = \OC::$server->getMemCacheFactory()->create('storageInfo');
$cached = $memcache->get($rootInfo ? '__root__' : $path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memcached has a limit of 250 chars. So you need to sha1 or something the path here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codecov-io
Copy link

Current coverage is 54.02% (diff: 84.21%)

Merging #3214 into master will increase coverage by 0.04%

@@             master      #3214   diff @@
==========================================
  Files          1298       1298          
  Lines         80110      80482   +372   
  Methods        7910       7953    +43   
  Messages          0          0          
  Branches       1248       1248          
==========================================
+ Hits          43239      43477   +238   
- Misses        36871      37005   +134   
  Partials          0          0          
Diff Coverage File Path
•••••••• 84% lib/private/legacy/helper.php

Powered by Codecov. Last update 5d48647...cbc18b7

@icewind1991 icewind1991 merged commit f55260b into master Jan 24, 2017
@icewind1991 icewind1991 deleted the cache-storage-info branch January 24, 2017 12:49
$cached = $memcache->get($cacheKey);
if (is_array($cached)) {
return $cached;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not unique across users. So this exposed the storage info of the user in the cache to all other users. Therefore I reverted this. #3515

Please come up with a proper implementation. And also take care of invalidate the cache when setting the quota.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants