Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: client/named_cache.py

Issue 2853413002: Add unit test to clean_caches() (Closed)
Patch Set: os.path.relpath Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/isolateserver.py ('k') | client/run_isolated.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/named_cache.py
diff --git a/client/named_cache.py b/client/named_cache.py
index 7566ccca9a5da9917e19e44584be641031861bdb..e3bf5e81c865e62c1235b0d4cb1f13917159c237 100644
--- a/client/named_cache.py
+++ b/client/named_cache.py
@@ -196,11 +196,15 @@ class CacheManager(object):
If min_free_space is None, disk free space is not checked.
Requires NamedCache to be open.
+
+ Returns:
+ Number of caches deleted.
"""
self._lock.assert_locked()
if not os.path.isdir(self.root_dir):
- return
+ return 0
+ total = 0
free_space = 0
if min_free_space:
free_space = file_path.get_free_space(self.root_dir)
@@ -212,7 +216,7 @@ class CacheManager(object):
try:
name, (path, _) = self._lru.get_oldest()
except KeyError:
- return
+ return total
named_dir = self._get_named_path(name)
if fs.islink(named_dir):
fs.unlink(named_dir)
@@ -223,6 +227,8 @@ class CacheManager(object):
if min_free_space:
free_space = file_path.get_free_space(self.root_dir)
self._lru.pop(name)
+ total += 1
+ return total
_DIR_ALPHABET = string.ascii_letters + string.digits
« no previous file with comments | « client/isolateserver.py ('k') | client/run_isolated.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698