nix copy: Make -r option use the "from" store
Previously, we tried to compute the closure in the local store, which obviously doesn't work.
This commit is contained in:
		
							parent
							
								
									287084d688
								
							
						
					
					
						commit
						558eda0115
					
				
					 3 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
					@ -79,9 +79,14 @@ StoreCommand::StoreCommand()
 | 
				
			||||||
    mkFlag(0, "store", "store-uri", "URI of the Nix store to use", &storeUri);
 | 
					    mkFlag(0, "store", "store-uri", "URI of the Nix store to use", &storeUri);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ref<Store> StoreCommand::createStore()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return openStore(storeUri);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void StoreCommand::run()
 | 
					void StoreCommand::run()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    run(openStore(storeUri));
 | 
					    run(createStore());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
StorePathsCommand::StorePathsCommand()
 | 
					StorePathsCommand::StorePathsCommand()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,6 +33,7 @@ struct StoreCommand : virtual Command
 | 
				
			||||||
    std::string storeUri;
 | 
					    std::string storeUri;
 | 
				
			||||||
    StoreCommand();
 | 
					    StoreCommand();
 | 
				
			||||||
    void run() override;
 | 
					    void run() override;
 | 
				
			||||||
 | 
					    virtual ref<Store> createStore();
 | 
				
			||||||
    virtual void run(ref<Store>) = 0;
 | 
					    virtual void run(ref<Store>) = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,13 +38,17 @@ struct CmdCopy : StorePathsCommand
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void run(ref<Store> store, Paths storePaths) override
 | 
					    ref<Store> createStore() override
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return srcUri.empty() ? StoreCommand::createStore() : openStore(srcUri);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void run(ref<Store> srcStore, Paths storePaths) override
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        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 : openStore(srcUri);
 | 
					        ref<Store> dstStore = dstUri.empty() ? openStore() : openStore(dstUri);
 | 
				
			||||||
        ref<Store> dstStore = dstUri.empty() ? store : openStore(dstUri);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        copyPaths(srcStore, dstStore, PathSet(storePaths.begin(), storePaths.end()));
 | 
					        copyPaths(srcStore, dstStore, PathSet(storePaths.begin(), storePaths.end()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue