From 538a64e8c314f23ba0c5d76201f1c20e71884a21 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 4 May 2016 13:36:54 +0200 Subject: Add a Store::addToStore() variant that accepts a NAR As a side effect, this ensures that signatures are propagated when copying paths between stores. Also refactored import/export to make use of this. --- src/libstore/store-api.hh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 95ad5136d965..f680e951f895 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -19,7 +19,7 @@ namespace nix { /* Size of the hash part of store paths, in base-32 characters. */ const size_t storePathHashLen = 32; // i.e. 160 bits -/* Magic header of exportPath() output. */ +/* Magic header of exportPath() output (obsolete). */ const uint32_t exportMagic = 0x4558494e; @@ -253,6 +253,10 @@ public: virtual void querySubstitutablePathInfos(const PathSet & paths, SubstitutablePathInfos & infos) = 0; + /* Import a path into the store. */ + virtual void addToStore(const ValidPathInfo & info, const std::string & nar, + bool repair = false) = 0; + /* Copy the contents of a path to the store and register the validity the resulting path. The resulting path is returned. The function object `filter' can be used to exclude files (see @@ -269,21 +273,6 @@ public: /* Write a NAR dump of a store path. */ virtual void narFromPath(const Path & path, Sink & sink) = 0; - /* Export a store path, that is, create a NAR dump of the store - path and append its references and its deriver. */ - virtual void exportPath(const Path & path, Sink & sink) = 0; - - /* Export multiple paths in the format expected by ‘nix-store - --import’. */ - void exportPaths(const Paths & paths, Sink & sink); - - /* Import a sequence of NAR dumps created by exportPaths() into - the Nix store. Optionally, the contents of the NARs are - preloaded into the specified FS accessor to speed up subsequent - access. */ - virtual Paths importPaths(Source & source, - std::shared_ptr accessor) = 0; - /* For each path, if it's a derivation, build it. Building a derivation means ensuring that the output paths are valid. If they are already valid, this is a no-op. Otherwise, validity @@ -397,6 +386,19 @@ public: relation. If p refers to q, then p preceeds q in this list. */ Paths topoSortPaths(const PathSet & paths); + /* Export multiple paths in the format expected by ‘nix-store + --import’. */ + void exportPaths(const Paths & paths, Sink & sink); + + void exportPath(const Path & path, Sink & sink); + + /* Import a sequence of NAR dumps created by exportPaths() into + the Nix store. Optionally, the contents of the NARs are + preloaded into the specified FS accessor to speed up subsequent + access. */ + Paths importPaths(Source & source, + std::shared_ptr accessor); + struct Stats { std::atomic narInfoRead{0}; -- cgit 1.4.1