BinaryCacheStore: Implement getBuildLog()
We assume that build logs are stored under log/<drv>, e.g. /nix/store/q7ab198v13p0f8x8wgnd75dva7d5mip6-friday-devil-0.1.1.1.drv maps to https://cache.nixos.org/log/q7ab198v13p0f8x8wgnd75dva7d5mip6-friday-devil-0.1.1.1.drv
This commit is contained in:
		
							parent
							
								
									5b86451f02
								
							
						
					
					
						commit
						532d73d5d8
					
				
					 3 changed files with 31 additions and 1 deletions
				
			
		|  | @ -382,4 +382,28 @@ ref<FSAccessor> BinaryCacheStore::getFSAccessor() | |||
|     return make_ref<RemoteFSAccessor>(ref<Store>(shared_from_this())); | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<std::string> BinaryCacheStore::getBuildLog(const Path & path) | ||||
| { | ||||
|     Path drvPath; | ||||
| 
 | ||||
|     if (isDerivation(path)) | ||||
|         drvPath = path; | ||||
|     else { | ||||
|         try { | ||||
|             auto info = queryPathInfo(path); | ||||
|             // FIXME: add a "Log" field to .narinfo
 | ||||
|             if (info->deriver == "") return nullptr; | ||||
|             drvPath = info->deriver; | ||||
|         } catch (InvalidPath &) { | ||||
|             return nullptr; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     auto logPath = "log/" + baseNameOf(drvPath); | ||||
| 
 | ||||
|     debug("fetching build log from binary cache ‘%s/%s’", getUri(), logPath); | ||||
| 
 | ||||
|     return getFile(logPath); | ||||
| } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -122,6 +122,8 @@ public: | |||
|     void addSignatures(const Path & storePath, const StringSet & sigs) override | ||||
|     { notImpl(); } | ||||
| 
 | ||||
|     std::shared_ptr<std::string> getBuildLog(const Path & path) override; | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -95,7 +95,11 @@ std::shared_ptr<std::string> LocalFSStore::getBuildLog(const Path & path_) | |||
|     assertStorePath(path); | ||||
| 
 | ||||
|     if (!isDerivation(path)) { | ||||
|         try { | ||||
|             path = queryPathInfo(path)->deriver; | ||||
|         } catch (InvalidPath &) { | ||||
|             return nullptr; | ||||
|         } | ||||
|         if (path == "") return nullptr; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue