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

Unified Diff: devserver.py

Issue 6254022: Don't wipe cache dir, only its contents. (Closed) Base URL: http://git.chromium.org/git/dev-util.git@master
Patch Set: Sanity check Created 9 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devserver.py
diff --git a/devserver.py b/devserver.py
index bf5e6d974abb2d432f745a36eea6559e9ab58cb9..47a576c1629615cb557c7a55cd2e9a6e48f89524 100755
--- a/devserver.py
+++ b/devserver.py
@@ -165,21 +165,24 @@ if __name__ == '__main__':
cache_dir = os.path.join(static_dir, 'cache')
cherrypy.log('Using cache directory %s' % cache_dir, 'DEVSERVER')
- if options.clear_cache:
- # Clear the cache and exit on error
- if os.system('sudo rm -rf %s' % cache_dir) != 0:
- cherrypy.log('Failed to clear the cache with %s' % cmd,
- 'DEVSERVER')
- sys.exit(1)
-
if os.path.exists(cache_dir):
- # Clear all but the last N cached updates
- cmd = ('cd %s; ls -tr | head --lines=-%d | xargs rm -rf' %
- (cache_dir, CACHED_ENTRIES))
- if os.system(cmd) != 0:
- cherrypy.log('Failed to clean up old delta cache files with %s' % cmd,
- 'DEVSERVER')
- sys.exit(1)
+ if options.clear_cache:
+ # Clear the cache and exit on error.
+ if os.system('rm -rf %s/*' % cache_dir) != 0:
+ cherrypy.log('Failed to clear the cache with %s' % cmd,
+ 'DEVSERVER')
+ sys.exit(1)
+
+ else:
+ # Clear all but the last N cached updates
+ cmd = ('cd %s; ls -tr | head --lines=-%d | xargs rm -rf' %
+ (cache_dir, CACHED_ENTRIES))
+ if os.system(cmd) != 0:
+ cherrypy.log('Failed to clean up old delta cache files with %s' % cmd,
+ 'DEVSERVER')
+ sys.exit(1)
+ else:
+ os.makedirs(cache_dir)
cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER')
cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698