build: don't generate patches mtime cache if it already exists (#26468)
This commit is contained in:
parent
e1cc78f275
commit
17df102a3b
1 changed files with 13 additions and 6 deletions
|
@ -105,10 +105,7 @@ def main():
|
|||
"generate", help="generate the mtime cache"
|
||||
)
|
||||
generate_subparser.add_argument(
|
||||
"--cache-file",
|
||||
type=argparse.FileType("w"),
|
||||
required=True,
|
||||
help="mtime cache file",
|
||||
"--cache-file", required=True, help="mtime cache file"
|
||||
)
|
||||
|
||||
set_subparser = subparsers.add_parser(
|
||||
|
@ -133,8 +130,18 @@ def main():
|
|||
|
||||
if args.operation == "generate":
|
||||
try:
|
||||
mtime_cache = generate_cache(json.load(args.patches_config))
|
||||
json.dump(mtime_cache, args.cache_file, indent=2)
|
||||
# Cache file may exist from a previously aborted sync. Reuse it.
|
||||
with open(args.cache_file, mode="r") as f:
|
||||
json.load(f) # Make sure it's not an empty file
|
||||
print("Using existing mtime cache for patches")
|
||||
return 0
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
with open(args.cache_file, mode="w") as f:
|
||||
mtime_cache = generate_cache(json.load(args.patches_config))
|
||||
json.dump(mtime_cache, f, indent=2)
|
||||
except Exception:
|
||||
print(
|
||||
"ERROR: failed to generate mtime cache for patches",
|
||||
|
|
Loading…
Reference in a new issue