(self)
| 50 | return self.cache_root_location |
| 51 | |
| 52 | def load_cache(self): |
| 53 | self.cached_files = [] |
| 54 | cache_keys_file_path = os.path.join(self.cache_root_location, |
| 55 | FileSystemCache.KEY_FILE_NAME) |
| 56 | if os.path.exists(cache_keys_file_path): |
| 57 | try: |
| 58 | with open(cache_keys_file_path, 'rb') as f: |
| 59 | data = pickle.load(f) |
| 60 | if isinstance(data, list): |
| 61 | self.cached_files = data |
| 62 | else: |
| 63 | logger.warning( |
| 64 | 'Cache index %s has unexpected type %s, resetting.', |
| 65 | cache_keys_file_path, |
| 66 | type(data).__name__) |
| 67 | except Exception as e: |
| 68 | logger.warning( |
| 69 | 'Failed to load cache index %s: %s. ' |
| 70 | 'Resetting — already-downloaded files will be re-validated on next run.', |
| 71 | cache_keys_file_path, e) |
| 72 | try: |
| 73 | os.replace(cache_keys_file_path, |
| 74 | cache_keys_file_path + '.corrupted') |
| 75 | except OSError: |
| 76 | pass |
| 77 | |
| 78 | def _save_cached_files_unlocked(self): |
| 79 | """Write .msc atomically. Caller must hold ``_cache_lock``.""" |
no test coverage detected