File tree 1 file changed +20
-13
lines changed
1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ def __init__(self):
48
48
49
49
self ._native_grep_available = False
50
50
51
+ self ._last_check_mutex = threading .RLock ()
51
52
self ._full_check_lock = threading .RLock ()
52
53
self ._check_result = {}
53
54
@@ -278,12 +279,13 @@ def _save_last_check_info(self):
278
279
}
279
280
280
281
try :
281
- with open (
282
- os .path .join (self .get_plugin_data_folder (), "last_check_info.json" ),
283
- "w" ,
284
- encoding = "utf-8" ,
285
- ) as f :
286
- data = json .dump (data , f )
282
+ with self ._last_check_mutex :
283
+ with open (
284
+ os .path .join (self .get_plugin_data_folder (), "last_check_info.json" ),
285
+ "w" ,
286
+ encoding = "utf-8" ,
287
+ ) as f :
288
+ data = json .dump (data , f )
287
289
except Exception :
288
290
self ._logger .exception (
289
291
"Could not save information about last full file check"
@@ -302,13 +304,18 @@ def _load_last_check_info(self):
302
304
return {}
303
305
304
306
try :
305
- with open (
306
- path ,
307
- encoding = "utf-8" ,
308
- ) as f :
309
- data = json .load (f )
310
- if isinstance (data , dict ) and "version" in data and "timestamp" in data :
311
- return data
307
+ with self ._last_check_mutex :
308
+ with open (
309
+ path ,
310
+ encoding = "utf-8" ,
311
+ ) as f :
312
+ data = json .load (f )
313
+ if (
314
+ isinstance (data , dict )
315
+ and "version" in data
316
+ and "timestamp" in data
317
+ ):
318
+ return data
312
319
except Exception :
313
320
self ._logger .exception (
314
321
"Could not load information about last full file check"
You can’t perform that action at this time.
0 commit comments