HttpBinaryCacheStore: Make thread-safe
This commit is contained in:
		
							parent
							
								
									c7d44bad00
								
							
						
					
					
						commit
						8b7839b608
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -10,7 +10,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     Path cacheUri; |     Path cacheUri; | ||||||
| 
 | 
 | ||||||
|     ref<Downloader> downloader; |     Pool<Downloader> downloaders; | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
| 
 | 
 | ||||||
|  | @ -18,7 +18,9 @@ public: | ||||||
|         const Path & secretKeyFile, const Path & _cacheUri) |         const Path & secretKeyFile, const Path & _cacheUri) | ||||||
|         : BinaryCacheStore(localStore, secretKeyFile) |         : BinaryCacheStore(localStore, secretKeyFile) | ||||||
|         , cacheUri(_cacheUri) |         , cacheUri(_cacheUri) | ||||||
|         , downloader(makeDownloader()) |         , downloaders( | ||||||
|  |             std::numeric_limits<size_t>::max(), | ||||||
|  |             []() { return makeDownloader(); }) | ||||||
|     { |     { | ||||||
|         if (cacheUri.back() == '/') |         if (cacheUri.back() == '/') | ||||||
|             cacheUri.pop_back(); |             cacheUri.pop_back(); | ||||||
|  | @ -36,6 +38,7 @@ protected: | ||||||
|     bool fileExists(const std::string & path) override |     bool fileExists(const std::string & path) override | ||||||
|     { |     { | ||||||
|         try { |         try { | ||||||
|  |             auto downloader(downloaders.get()); | ||||||
|             DownloadOptions options; |             DownloadOptions options; | ||||||
|             options.showProgress = DownloadOptions::no; |             options.showProgress = DownloadOptions::no; | ||||||
|             options.head = true; |             options.head = true; | ||||||
|  | @ -55,6 +58,7 @@ protected: | ||||||
| 
 | 
 | ||||||
|     std::string getFile(const std::string & path) override |     std::string getFile(const std::string & path) override | ||||||
|     { |     { | ||||||
|  |         auto downloader(downloaders.get()); | ||||||
|         DownloadOptions options; |         DownloadOptions options; | ||||||
|         options.showProgress = DownloadOptions::no; |         options.showProgress = DownloadOptions::no; | ||||||
|         return downloader->download(cacheUri + "/" + path, options).data; |         return downloader->download(cacheUri + "/" + path, options).data; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue