about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T19·09-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T19·09-0400
commit0a7084567fc4e7d077863075a7ea1bb82d843341 (patch)
tree4868d450da1e153b0660eede85105cb2b14d0859 /src/libstore/local-store.cc
parenta807edfae8428bf426ee6ae849a7a24d74d39202 (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.cc16
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);