addToStore(): Take explicit name argument
This commit is contained in:
parent
5114a07d95
commit
7ea6ecf855
|
@ -282,7 +282,7 @@ SV * addToStore(char * srcPath, int recursive, char * algo)
|
||||||
PPCODE:
|
PPCODE:
|
||||||
try {
|
try {
|
||||||
doInit();
|
doInit();
|
||||||
Path path = store->addToStore(srcPath, recursive, parseHashType(algo));
|
Path path = store->addToStore(baseNameOf(srcPath), srcPath, recursive, parseHashType(algo));
|
||||||
XPUSHs(sv_2mortal(newSVpv(path.c_str(), 0)));
|
XPUSHs(sv_2mortal(newSVpv(path.c_str(), 0)));
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
croak(e.what());
|
croak(e.what());
|
||||||
|
|
|
@ -1419,7 +1419,7 @@ string EvalState::copyPathToStore(PathSet & context, const Path & path)
|
||||||
else {
|
else {
|
||||||
dstPath = settings.readOnlyMode
|
dstPath = settings.readOnlyMode
|
||||||
? computeStorePathForPath(checkSourcePath(path)).first
|
? computeStorePathForPath(checkSourcePath(path)).first
|
||||||
: store->addToStore(checkSourcePath(path), true, htSHA256, defaultPathFilter, repair);
|
: store->addToStore(baseNameOf(path), checkSourcePath(path), true, htSHA256, defaultPathFilter, repair);
|
||||||
srcToStore[path] = dstPath;
|
srcToStore[path] = dstPath;
|
||||||
printMsg(lvlChatty, format("copied source ‘%1%’ -> ‘%2%’")
|
printMsg(lvlChatty, format("copied source ‘%1%’ -> ‘%2%’")
|
||||||
% path % dstPath);
|
% path % dstPath);
|
||||||
|
|
|
@ -943,7 +943,7 @@ static void prim_filterSource(EvalState & state, const Pos & pos, Value * * args
|
||||||
|
|
||||||
Path dstPath = settings.readOnlyMode
|
Path dstPath = settings.readOnlyMode
|
||||||
? computeStorePathForPath(path, true, htSHA256, filter).first
|
? computeStorePathForPath(path, true, htSHA256, filter).first
|
||||||
: store->addToStore(path, true, htSHA256, filter, state.repair);
|
: store->addToStore(baseNameOf(path), path, true, htSHA256, filter, state.repair);
|
||||||
|
|
||||||
mkString(v, dstPath, singleton<PathSet>(dstPath));
|
mkString(v, dstPath, singleton<PathSet>(dstPath));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,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");
|
||||||
|
@ -397,7 +397,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);
|
||||||
|
|
|
@ -53,7 +53,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);
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,8 @@ static void opAdd(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||||
|
|
||||||
for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i)
|
for (auto & i : opArgs)
|
||||||
cout << format("%1%\n") % store->addToStore(*i);
|
cout << format("%1%\n") % store->addToStore(baseNameOf(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ static void opAddFixed(Strings opFlags, Strings opArgs)
|
||||||
HashType hashAlgo = parseHashType(opArgs.front());
|
HashType hashAlgo = parseHashType(opArgs.front());
|
||||||
opArgs.pop_front();
|
opArgs.pop_front();
|
||||||
|
|
||||||
for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i)
|
for (auto & i : opArgs)
|
||||||
cout << format("%1%\n") % store->addToStore(*i, recursive, hashAlgo);
|
cout << format("%1%\n") % store->addToStore(baseNameOf(i), i, recursive, hashAlgo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue