Skip to content

Commit 17df102

Browse files
authored
build: don't generate patches mtime cache if it already exists (electron#26468)
1 parent e1cc78f commit 17df102

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

script/patches-mtime-cache.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ def main():
105105
"generate", help="generate the mtime cache"
106106
)
107107
generate_subparser.add_argument(
108-
"--cache-file",
109-
type=argparse.FileType("w"),
110-
required=True,
111-
help="mtime cache file",
108+
"--cache-file", required=True, help="mtime cache file"
112109
)
113110

114111
set_subparser = subparsers.add_parser(
@@ -133,8 +130,18 @@ def main():
133130

134131
if args.operation == "generate":
135132
try:
136-
mtime_cache = generate_cache(json.load(args.patches_config))
137-
json.dump(mtime_cache, args.cache_file, indent=2)
133+
# Cache file may exist from a previously aborted sync. Reuse it.
134+
with open(args.cache_file, mode="r") as f:
135+
json.load(f) # Make sure it's not an empty file
136+
print("Using existing mtime cache for patches")
137+
return 0
138+
except:
139+
pass
140+
141+
try:
142+
with open(args.cache_file, mode="w") as f:
143+
mtime_cache = generate_cache(json.load(args.patches_config))
144+
json.dump(mtime_cache, f, indent=2)
138145
except Exception:
139146
print(
140147
"ERROR: failed to generate mtime cache for patches",

0 commit comments

Comments
 (0)