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

Unified Diff: download_firefox_nightly.py

Issue 891303002: Now cleaning old firefox archives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/
Patch Set: Created 5 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 | « DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: download_firefox_nightly.py
===================================================================
--- download_firefox_nightly.py (revision 293895)
+++ download_firefox_nightly.py (working copy)
@@ -31,12 +31,35 @@
os.utime(a_file, None)
-def _FindFallbackFirefoxBuild(target_dir):
+def _GetFirefoxArchivesSortedOnModifiedDate(target_dir):
firefox_archives = glob.glob(os.path.join(target_dir, '*tar.bz2'))
if not firefox_archives:
return None
firefox_archives.sort(key=os.path.getmtime, reverse=True)
+ return firefox_archives
+
+
+def _CleanOldFirefoxArchives(target_dir):
+ firefox_archives = _GetFirefoxArchivesSortedOnModifiedDate(target_dir)
+ if not firefox_archives or len(firefox_archives) < 2:
+ return
+
+ # Keep the newest archive around as a fallback build and delete the rest.
+ rest = firefox_archives[1:]
+ print 'About to delete old Firefox archives %s.' % rest
+ for old_archive in rest:
+ try:
+ os.remove(old_archive)
+ except OSError:
+ pass
+
+
+def _FindFallbackFirefoxBuild(target_dir):
+ firefox_archives = _GetFirefoxArchivesSortedOnModifiedDate(target_dir)
+ if not firefox_archives:
+ return None
+
newest_build = firefox_archives[0]
build_age_seconds = time.time() - os.path.getmtime(newest_build)
build_age_days = datetime.timedelta(seconds=build_age_seconds).days
@@ -116,6 +139,9 @@
parser.add_option('-f', '--force', action='store_true',
help=('Force download even if the current nightly is '
'already downloaded.'))
+ parser.add_option('-c', '--clean-old-archives', action='store_true',
+ help=('Clean old firefox archives; one will always be '
+ 'kept as a fallback.'))
options, _args = parser.parse_args()
if not options.target_dir:
parser.error('You must specify the target directory.')
@@ -128,5 +154,8 @@
if firefox_archive:
return _ExtractArchive(firefox_archive, target_dir)
+ if options.clean_old_archives:
+ _CleanOldFirefoxArchives(target_dir)
+
if __name__ == '__main__':
sys.exit(main())
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698