| 145 | KeyIndexFileCache::~KeyIndexFileCache() = default; |
| 146 | |
| 147 | void KeyIndexFileCache::initCacheFromFileSystem() |
| 148 | { |
| 149 | LOG_INFO(log, "Initializing KeyIndexFileCache..."); |
| 150 | Poco::File(rep->base_path).createDirectories(); |
| 151 | |
| 152 | Stopwatch timer; |
| 153 | int num_loaded = 0; |
| 154 | Poco::DirectoryIterator end; |
| 155 | for (auto it = Poco::DirectoryIterator(rep->base_path); it != end; ++it) |
| 156 | { |
| 157 | auto & filename = it.name(); |
| 158 | if (startsWith(filename, "TMP_")) |
| 159 | { |
| 160 | LOG_TRACE(log, "Removing temporary file {}", it->path()); |
| 161 | Poco::File(it->path()).remove(); |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | String key; |
| 166 | UInt64 size; |
| 167 | if (tryParseCacheFileName(filename, key, size)) |
| 168 | { |
| 169 | rep->cache.set(key, CacheValue::Cached(size)); |
| 170 | num_loaded++; |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | LOG_WARNING(log, "Unrecognized name for unique key index cache file: {}", filename); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | LOG_INFO(log, "Initialized KeyIndexFileCache with {} entries in {} ms", num_loaded, timer.elapsedMilliseconds()); |
| 179 | } |
| 180 | |
| 181 | int KeyIndexFileCache::get(const IndexFile::RemoteFileInfo & file) |
| 182 | { |
nothing calls this directly
no test coverage detected