зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1626393 - [tryselect] Catch OSError to check for file existence while invalidating task caches, r=gbrown
This prevents a race condition where the watchman hook can potentially invalidate the cache in-between the call to 'isfile' and 'getmtime'. Depends on D69189 Differential Revision: https://phabricator.services.mozilla.com/D69190 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
be64ef9701
Коммит
ba40f078a0
|
@ -40,12 +40,19 @@ https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/mach.html#parame
|
|||
|
||||
|
||||
def invalidate(cache):
|
||||
if not os.path.isfile(cache):
|
||||
return
|
||||
try:
|
||||
cmod = os.path.getmtime(cache)
|
||||
except OSError as e:
|
||||
# File does not exist. We catch OSError rather than use `isfile`
|
||||
# because the recommended watchman hook could possibly invalidate the
|
||||
# cache in-between the check to `isfile` and the call to `getmtime`
|
||||
# below.
|
||||
if e.errno == 2:
|
||||
return
|
||||
raise
|
||||
|
||||
tc_dir = os.path.join(build.topsrcdir, 'taskcluster')
|
||||
tmod = max(os.path.getmtime(os.path.join(tc_dir, p)) for p, _ in FileFinder(tc_dir))
|
||||
cmod = os.path.getmtime(cache)
|
||||
|
||||
if tmod > cmod:
|
||||
os.remove(cache)
|
||||
|
|
Загрузка…
Ссылка в новой задаче