@@ -85,6 +85,10 @@ def load_or_build(
8585 # bypass build if cache exists
8686 if has_cache and not force :
8787 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 )
8892 return load_cache_file (cache_file )
8993 except Exception as e :
9094 # work around some rare Windows quirks
@@ -387,12 +391,13 @@ def need_cache_rebuild(additional_directories):
387391 # if we have cached additional directories of licenses, check if those licenses are equal to the additional
388392 # directories passed in
389393 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 ()
391396
392397 # we need to rebuild the cache if the list of additional directories we passed in is not a subset of
393398 # 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 )
396401 else :
397402 # otherwise, we don't have a file of cached directories. If there are additional directories passed in,
398403 # we know we need to make a new cache file.
0 commit comments