Merge openStore and openStoreAt with default arguments
This commit is contained in:
		
							parent
							
								
									87b189c2b3
								
							
						
					
					
						commit
						a91954f0c6
					
				
					 6 changed files with 8 additions and 18 deletions
				
			
		|  | @ -506,7 +506,7 @@ namespace nix { | ||||||
| RegisterStoreImplementation::Implementations * RegisterStoreImplementation::implementations = 0; | RegisterStoreImplementation::Implementations * RegisterStoreImplementation::implementations = 0; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| ref<Store> openStoreAt(const std::string & uri_) | ref<Store> openStore(const std::string & uri_) | ||||||
| { | { | ||||||
|     auto uri(uri_); |     auto uri(uri_); | ||||||
|     Store::Params params; |     Store::Params params; | ||||||
|  | @ -529,12 +529,6 @@ ref<Store> openStoreAt(const std::string & uri_) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| ref<Store> openStore() |  | ||||||
| { |  | ||||||
|     return openStoreAt(getEnv("NIX_REMOTE")); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| static RegisterStoreImplementation regStore([]( | static RegisterStoreImplementation regStore([]( | ||||||
|     const std::string & uri, const Store::Params & params) |     const std::string & uri, const Store::Params & params) | ||||||
|     -> std::shared_ptr<Store> |     -> std::shared_ptr<Store> | ||||||
|  | @ -579,7 +573,7 @@ std::list<ref<Store>> getDefaultSubstituters() | ||||||
|     auto addStore = [&](const std::string & uri) { |     auto addStore = [&](const std::string & uri) { | ||||||
|         if (done.count(uri)) return; |         if (done.count(uri)) return; | ||||||
|         done.insert(uri); |         done.insert(uri); | ||||||
|         state->stores.push_back(openStoreAt(uri)); |         state->stores.push_back(openStore(uri)); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     for (auto uri : settings.get("substituters", Strings())) |     for (auto uri : settings.get("substituters", Strings())) | ||||||
|  |  | ||||||
|  | @ -587,11 +587,7 @@ void removeTempRoots(); | ||||||
|    If ‘uri’ is empty, it defaults to ‘direct’ or ‘daemon’ depending on |    If ‘uri’ is empty, it defaults to ‘direct’ or ‘daemon’ depending on | ||||||
|    whether the user has write access to the local Nix store/database. |    whether the user has write access to the local Nix store/database. | ||||||
|    set to true *unless* you're going to collect garbage. */ |    set to true *unless* you're going to collect garbage. */ | ||||||
| ref<Store> openStoreAt(const std::string & uri); | ref<Store> openStore(const std::string & uri = getEnv("NIX_REMOTE")); | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /* Open the store indicated by the ‘NIX_REMOTE’ environment variable. */ |  | ||||||
| ref<Store> openStore(); |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* Return the default substituter stores, defined by the
 | /* Return the default substituter stores, defined by the
 | ||||||
|  |  | ||||||
|  | @ -81,7 +81,7 @@ StoreCommand::StoreCommand() | ||||||
| 
 | 
 | ||||||
| void StoreCommand::run() | void StoreCommand::run() | ||||||
| { | { | ||||||
|     run(openStoreAt(storeUri)); |     run(openStore(storeUri)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| StorePathsCommand::StorePathsCommand() | StorePathsCommand::StorePathsCommand() | ||||||
|  |  | ||||||
|  | @ -43,8 +43,8 @@ struct CmdCopy : StorePathsCommand | ||||||
|         if (srcUri.empty() && dstUri.empty()) |         if (srcUri.empty() && dstUri.empty()) | ||||||
|             throw UsageError("you must pass ‘--from’ and/or ‘--to’"); |             throw UsageError("you must pass ‘--from’ and/or ‘--to’"); | ||||||
| 
 | 
 | ||||||
|         ref<Store> srcStore = srcUri.empty() ? store : openStoreAt(srcUri); |         ref<Store> srcStore = srcUri.empty() ? store : openStore(srcUri); | ||||||
|         ref<Store> dstStore = dstUri.empty() ? store : openStoreAt(dstUri); |         ref<Store> dstStore = dstUri.empty() ? store : openStore(dstUri); | ||||||
| 
 | 
 | ||||||
|         std::string copiedLabel = "copied"; |         std::string copiedLabel = "copied"; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ struct CmdCopySigs : StorePathsCommand | ||||||
|         // FIXME: factor out commonality with MixVerify.
 |         // FIXME: factor out commonality with MixVerify.
 | ||||||
|         std::vector<ref<Store>> substituters; |         std::vector<ref<Store>> substituters; | ||||||
|         for (auto & s : substituterUris) |         for (auto & s : substituterUris) | ||||||
|             substituters.push_back(openStoreAt(s)); |             substituters.push_back(openStore(s)); | ||||||
| 
 | 
 | ||||||
|         ThreadPool pool; |         ThreadPool pool; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -52,7 +52,7 @@ struct CmdVerify : StorePathsCommand | ||||||
|     { |     { | ||||||
|         std::vector<ref<Store>> substituters; |         std::vector<ref<Store>> substituters; | ||||||
|         for (auto & s : substituterUris) |         for (auto & s : substituterUris) | ||||||
|             substituters.push_back(openStoreAt(s)); |             substituters.push_back(openStore(s)); | ||||||
| 
 | 
 | ||||||
|         auto publicKeys = getDefaultPublicKeys(); |         auto publicKeys = getDefaultPublicKeys(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue