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", help="generate the mtime cache"
|
||||||
)
|
)
|
||||||
generate_subparser.add_argument(
|
generate_subparser.add_argument(
|
||||||
"--cache-file",
|
"--cache-file", required=True, help="mtime cache file"
|
||||||
type=argparse.FileType("w"),
|
|
||||||
required=True,
|
|
||||||
help="mtime cache file",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_subparser = subparsers.add_parser(
|
set_subparser = subparsers.add_parser(
|
||||||
|
@ -133,8 +130,18 @@ def main():
|
||||||
|
|
||||||
if args.operation == "generate":
|
if args.operation == "generate":
|
||||||
try:
|
try:
|
||||||
|
# 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))
|
mtime_cache = generate_cache(json.load(args.patches_config))
|
||||||
json.dump(mtime_cache, args.cache_file, indent=2)
|
json.dump(mtime_cache, f, indent=2)
|
||||||
except Exception:
|
except Exception:
|
||||||
print(
|
print(
|
||||||
"ERROR: failed to generate mtime cache for patches",
|
"ERROR: failed to generate mtime cache for patches",
|
||||||
|
|
Loading…
Add table
Reference in a new issue