@@ -85,6 +85,10 @@ def load_or_build(
85
85
# bypass build if cache exists
86
86
if has_cache and not force :
87
87
try :
88
+ # save the list of additional directories included in the cache, or None if the cache does not
89
+ # include any additional directories
90
+ with open (cached_directories_file , 'wb' ) as file :
91
+ pickle .dump (additional_directories , file , protocol = PICKLE_PROTOCOL )
88
92
return load_cache_file (cache_file )
89
93
except Exception as e :
90
94
# work around some rare Windows quirks
@@ -387,12 +391,13 @@ def need_cache_rebuild(additional_directories):
387
391
# if we have cached additional directories of licenses, check if those licenses are equal to the additional
388
392
# directories passed in
389
393
with open (cached_directories_file , 'rb' ) as file :
390
- cached_additional_directories = pickle .load (file )
394
+ # it's possible that pickle.load(file) results in None
395
+ cached_additional_directories = pickle .load (file ) or set ()
391
396
392
397
# we need to rebuild the cache if the list of additional directories we passed in is not a subset of
393
398
# the set of additional directories currently included in the index cache
394
- should_rebuild_cache = additional_directories is not None and cached_additional_directories is not None \
395
- and not set (additional_directories ).issubset (set ( cached_additional_directories ) )
399
+ should_rebuild_cache = additional_directories is not None \
400
+ and not set (additional_directories ).issubset (cached_additional_directories )
396
401
else :
397
402
# otherwise, we don't have a file of cached directories. If there are additional directories passed in,
398
403
# we know we need to make a new cache file.
0 commit comments