@@ -105,10 +105,7 @@ def main():
105
105
"generate" , help = "generate the mtime cache"
106
106
)
107
107
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"
112
109
)
113
110
114
111
set_subparser = subparsers .add_parser (
@@ -133,8 +130,18 @@ def main():
133
130
134
131
if args .operation == "generate" :
135
132
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 )
138
145
except Exception :
139
146
print (
140
147
"ERROR: failed to generate mtime cache for patches" ,
0 commit comments