diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-10-03T19·09-0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-10-03T19·09-0400 |
commit | 0a7084567fc4e7d077863075a7ea1bb82d843341 (patch) | |
tree | 4868d450da1e153b0660eede85105cb2b14d0859 /src/libstore/local-store.cc | |
parent | a807edfae8428bf426ee6ae849a7a24d74d39202 (diff) |
Add a ‘--repair’ flag to nix-instantiate
This allows repairing corrupted derivations and other source files.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index b55ab428421f..982644af7154 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1158,7 +1158,7 @@ void LocalStore::invalidatePath(const Path & path) Path LocalStore::addToStoreFromDump(const string & dump, const string & name, - bool recursive, HashType hashAlgo) + bool recursive, HashType hashAlgo, bool repair) { Hash h = hashString(hashAlgo, dump); @@ -1166,14 +1166,14 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name, addTempRoot(dstPath); - if (!isValidPath(dstPath)) { + if (repair || !isValidPath(dstPath)) { /* The first check above is an optimisation to prevent unnecessary lock acquisition. */ PathLocks outputLock(singleton<PathSet, Path>(dstPath)); - if (!isValidPath(dstPath)) { + if (repair || !isValidPath(dstPath)) { if (pathExists(dstPath)) deletePathWrapped(dstPath); @@ -1213,7 +1213,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name, Path LocalStore::addToStore(const Path & _srcPath, - bool recursive, HashType hashAlgo, PathFilter & filter) + bool recursive, HashType hashAlgo, PathFilter & filter, bool repair) { Path srcPath(absPath(_srcPath)); debug(format("adding `%1%' to the store") % srcPath); @@ -1227,22 +1227,22 @@ Path LocalStore::addToStore(const Path & _srcPath, else sink.s = readFile(srcPath); - return addToStoreFromDump(sink.s, baseNameOf(srcPath), recursive, hashAlgo); + return addToStoreFromDump(sink.s, baseNameOf(srcPath), recursive, hashAlgo, repair); } Path LocalStore::addTextToStore(const string & name, const string & s, - const PathSet & references) + const PathSet & references, bool repair) { Path dstPath = computeStorePathForText(name, s, references); addTempRoot(dstPath); - if (!isValidPath(dstPath)) { + if (repair || !isValidPath(dstPath)) { PathLocks outputLock(singleton<PathSet, Path>(dstPath)); - if (!isValidPath(dstPath)) { + if (repair || !isValidPath(dstPath)) { if (pathExists(dstPath)) deletePathWrapped(dstPath); |