From fcc1e1427cb72a2cd872a6893a5f64c63e27f0ed Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 1 Feb 2018 22:19:29 +0000 Subject: [PATCH] Don't download gecko prefs file if it's reasonably new --- tools/wpt/browser.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/wpt/browser.py b/tools/wpt/browser.py index ef3b7d6694bcfc..a76074bb28424c 100644 --- a/tools/wpt/browser.py +++ b/tools/wpt/browser.py @@ -8,6 +8,7 @@ import sys from abc import ABCMeta, abstractmethod from ConfigParser import RawConfigParser +from datetime import datetime, timedelta from distutils.spawn import find_executable from io import BytesIO @@ -158,9 +159,15 @@ def install_prefs(self, dest=None): dest = os.path.join(dest, "profiles") if not os.path.exists(dest): os.makedirs(dest) - with open(os.path.join(dest, "prefs_general.js"), "wb") as f: - resp = get("https://hg.mozilla.org/mozilla-central/raw-file/tip/testing/profiles/prefs_general.js") - f.write(resp.content) + prefs_path = os.path.join(dest, "prefs_general.js") + + now = datetime.now() + if (not os.path.exists(prefs_path) or + (datetime.fromtimestamp(os.stat(prefs_path).st_mtime) < + now - timedelta(days=2))): + with open(prefs_path, "wb") as f: + resp = get("https://hg.mozilla.org/mozilla-central/raw-file/tip/testing/profiles/prefs_general.js") + f.write(resp.content) return dest