From 0a7084567fc4e7d077863075a7ea1bb82d843341 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Oct 2012 15:09:18 -0400 Subject: Add a ‘--repair’ flag to nix-instantiate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows repairing corrupted derivations and other source files. --- src/libstore/local-store.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libstore/local-store.cc') 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(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(dstPath)); - if (!isValidPath(dstPath)) { + if (repair || !isValidPath(dstPath)) { if (pathExists(dstPath)) deletePathWrapped(dstPath); -- cgit 1.4.1