addToStore(): Take explicit name argument

This commit is contained in:
Eelco Dolstra 2015-03-25 17:06:12 +01:00 committed by Ludovic Courtès
parent 1f595ba474
commit b6ecbd266f
5 changed files with 29 additions and 29 deletions

View File

@ -1405,7 +1405,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
} }
Path LocalStore::addToStore(const Path & _srcPath, Path LocalStore::addToStore(const string & name, const Path & _srcPath,
bool recursive, HashType hashAlgo, PathFilter & filter, bool repair) bool recursive, HashType hashAlgo, PathFilter & filter, bool repair)
{ {
Path srcPath(absPath(_srcPath)); Path srcPath(absPath(_srcPath));
@ -1420,7 +1420,7 @@ Path LocalStore::addToStore(const Path & _srcPath,
else else
sink.s = readFile(srcPath); sink.s = readFile(srcPath);
return addToStoreFromDump(sink.s, baseNameOf(srcPath), recursive, hashAlgo, repair); return addToStoreFromDump(sink.s, name, recursive, hashAlgo, repair);
} }

View File

@ -130,7 +130,7 @@ public:
void querySubstitutablePathInfos(const PathSet & paths, void querySubstitutablePathInfos(const PathSet & paths,
SubstitutablePathInfos & infos); SubstitutablePathInfos & infos);
Path addToStore(const Path & srcPath, Path addToStore(const string & name, const Path & srcPath,
bool recursive = true, HashType hashAlgo = htSHA256, bool recursive = true, HashType hashAlgo = htSHA256,
PathFilter & filter = defaultPathFilter, bool repair = false); PathFilter & filter = defaultPathFilter, bool repair = false);

View File

@ -385,7 +385,7 @@ Path RemoteStore::queryPathFromHashPart(const string & hashPart)
} }
Path RemoteStore::addToStore(const Path & _srcPath, Path RemoteStore::addToStore(const string & name, const Path & _srcPath,
bool recursive, HashType hashAlgo, PathFilter & filter, bool repair) bool recursive, HashType hashAlgo, PathFilter & filter, bool repair)
{ {
if (repair) throw Error("repairing is not supported when building through the Nix daemon"); if (repair) throw Error("repairing is not supported when building through the Nix daemon");
@ -395,7 +395,7 @@ Path RemoteStore::addToStore(const Path & _srcPath,
Path srcPath(absPath(_srcPath)); Path srcPath(absPath(_srcPath));
writeInt(wopAddToStore, to); writeInt(wopAddToStore, to);
writeString(baseNameOf(srcPath), to); writeString(name, to);
/* backwards compatibility hack */ /* backwards compatibility hack */
writeInt((hashAlgo == htSHA256 && recursive) ? 0 : 1, to); writeInt((hashAlgo == htSHA256 && recursive) ? 0 : 1, to);
writeInt(recursive ? 1 : 0, to); writeInt(recursive ? 1 : 0, to);

View File

@ -21,15 +21,15 @@ public:
RemoteStore(); RemoteStore();
~RemoteStore(); ~RemoteStore();
/* Implementations of abstract store API methods. */ /* Implementations of abstract store API methods. */
bool isValidPath(const Path & path); bool isValidPath(const Path & path);
PathSet queryValidPaths(const PathSet & paths); PathSet queryValidPaths(const PathSet & paths);
PathSet queryAllValidPaths(); PathSet queryAllValidPaths();
ValidPathInfo queryPathInfo(const Path & path); ValidPathInfo queryPathInfo(const Path & path);
Hash queryPathHash(const Path & path); Hash queryPathHash(const Path & path);
@ -39,21 +39,21 @@ public:
void queryReferrers(const Path & path, PathSet & referrers); void queryReferrers(const Path & path, PathSet & referrers);
Path queryDeriver(const Path & path); Path queryDeriver(const Path & path);
PathSet queryValidDerivers(const Path & path); PathSet queryValidDerivers(const Path & path);
PathSet queryDerivationOutputs(const Path & path); PathSet queryDerivationOutputs(const Path & path);
StringSet queryDerivationOutputNames(const Path & path); StringSet queryDerivationOutputNames(const Path & path);
Path queryPathFromHashPart(const string & hashPart); Path queryPathFromHashPart(const string & hashPart);
PathSet querySubstitutablePaths(const PathSet & paths); PathSet querySubstitutablePaths(const PathSet & paths);
void querySubstitutablePathInfos(const PathSet & paths, void querySubstitutablePathInfos(const PathSet & paths,
SubstitutablePathInfos & infos); SubstitutablePathInfos & infos);
Path addToStore(const Path & srcPath, Path addToStore(const string & name, const Path & srcPath,
bool recursive = true, HashType hashAlgo = htSHA256, bool recursive = true, HashType hashAlgo = htSHA256,
PathFilter & filter = defaultPathFilter, bool repair = false); PathFilter & filter = defaultPathFilter, bool repair = false);
@ -64,7 +64,7 @@ public:
Sink & sink); Sink & sink);
Paths importPaths(bool requireSignature, Source & source); Paths importPaths(bool requireSignature, Source & source);
void buildPaths(const PathSet & paths, BuildMode buildMode); void buildPaths(const PathSet & paths, BuildMode buildMode);
void ensurePath(const Path & path); void ensurePath(const Path & path);
@ -72,13 +72,13 @@ public:
void addTempRoot(const Path & path); void addTempRoot(const Path & path);
void addIndirectRoot(const Path & path); void addIndirectRoot(const Path & path);
void syncWithGC(); void syncWithGC();
Roots findRoots(); Roots findRoots();
void collectGarbage(const GCOptions & options, GCResults & results); void collectGarbage(const GCOptions & options, GCResults & results);
PathSet queryFailedPaths(); PathSet queryFailedPaths();
void clearFailedPaths(const PathSet & paths); void clearFailedPaths(const PathSet & paths);

View File

@ -54,7 +54,7 @@ struct GCOptions
}; };
struct GCResults struct GCResults
{ {
/* Depending on the action, the GC roots, or the paths that would /* Depending on the action, the GC roots, or the paths that would
be or have been deleted. */ be or have been deleted. */
@ -82,7 +82,7 @@ struct SubstitutablePathInfo
typedef std::map<Path, SubstitutablePathInfo> SubstitutablePathInfos; typedef std::map<Path, SubstitutablePathInfo> SubstitutablePathInfos;
struct ValidPathInfo struct ValidPathInfo
{ {
Path path; Path path;
Path deriver; Path deriver;
@ -100,13 +100,13 @@ typedef list<ValidPathInfo> ValidPathInfos;
enum BuildMode { bmNormal, bmRepair, bmCheck }; enum BuildMode { bmNormal, bmRepair, bmCheck };
class StoreAPI class StoreAPI
{ {
public: public:
virtual ~StoreAPI() { } virtual ~StoreAPI() { }
/* Check whether a path is valid. */ /* Check whether a path is valid. */
virtual bool isValidPath(const Path & path) = 0; virtual bool isValidPath(const Path & path) = 0;
/* Query which of the given paths is valid. */ /* Query which of the given paths is valid. */
@ -118,7 +118,7 @@ public:
/* Query information about a valid path. */ /* Query information about a valid path. */
virtual ValidPathInfo queryPathInfo(const Path & path) = 0; virtual ValidPathInfo queryPathInfo(const Path & path) = 0;
/* Query the hash of a valid path. */ /* Query the hash of a valid path. */
virtual Hash queryPathHash(const Path & path) = 0; virtual Hash queryPathHash(const Path & path) = 0;
/* Query the set of outgoing FS references for a store path. The /* Query the set of outgoing FS references for a store path. The
@ -150,7 +150,7 @@ public:
/* Query the full store path given the hash part of a valid store /* Query the full store path given the hash part of a valid store
path, or "" if the path doesn't exist. */ path, or "" if the path doesn't exist. */
virtual Path queryPathFromHashPart(const string & hashPart) = 0; virtual Path queryPathFromHashPart(const string & hashPart) = 0;
/* Query which of the given paths have substitutes. */ /* Query which of the given paths have substitutes. */
virtual PathSet querySubstitutablePaths(const PathSet & paths) = 0; virtual PathSet querySubstitutablePaths(const PathSet & paths) = 0;
@ -159,12 +159,12 @@ public:
info, it's omitted from the resulting infos map. */ info, it's omitted from the resulting infos map. */
virtual void querySubstitutablePathInfos(const PathSet & paths, virtual void querySubstitutablePathInfos(const PathSet & paths,
SubstitutablePathInfos & infos) = 0; SubstitutablePathInfos & infos) = 0;
/* Copy the contents of a path to the store and register the /* Copy the contents of a path to the store and register the
validity the resulting path. The resulting path is returned. validity the resulting path. The resulting path is returned.
The function object `filter' can be used to exclude files (see The function object `filter' can be used to exclude files (see
libutil/archive.hh). */ libutil/archive.hh). */
virtual Path addToStore(const Path & srcPath, virtual Path addToStore(const string & name, const Path & srcPath,
bool recursive = true, HashType hashAlgo = htSHA256, bool recursive = true, HashType hashAlgo = htSHA256,
PathFilter & filter = defaultPathFilter, bool repair = false) = 0; PathFilter & filter = defaultPathFilter, bool repair = false) = 0;
@ -267,7 +267,7 @@ bool isStorePath(const Path & path);
/* Extract the name part of the given store path. */ /* Extract the name part of the given store path. */
string storePathToName(const Path & path); string storePathToName(const Path & path);
void checkStoreName(const string & name); void checkStoreName(const string & name);
@ -288,7 +288,7 @@ Path followLinksToStorePath(const Path & path);
/* Constructs a unique store path name. */ /* Constructs a unique store path name. */
Path makeStorePath(const string & type, Path makeStorePath(const string & type,
const Hash & hash, const string & name); const Hash & hash, const string & name);
Path makeOutputPath(const string & id, Path makeOutputPath(const string & id,
const Hash & hash, const string & name); const Hash & hash, const string & name);