From 2001895f3d2668549feb60a182aa624a7b6292eb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 Oct 2012 17:13:46 -0400 Subject: Add a --repair flag to ‘nix-store -r’ to repair derivation outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this flag, if any valid derivation output is missing or corrupt, it will be recreated by using a substitute if available, or by rebuilding the derivation. The latter may use hash rewriting if chroots are not available. --- src/libstore/local-store.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libstore/local-store.cc') diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index e038cd4b29d3..a4ad97331ad3 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1671,6 +1671,16 @@ void LocalStore::verifyPath(const Path & path, const PathSet & store, } +bool LocalStore::pathContentsGood(const Path & path) +{ + ValidPathInfo info = queryPathInfo(path); + if (!pathExists(path)) return false; + HashResult current = hashPath(info.hash.type, path); + Hash nullHash(htSHA256); + return info.hash == nullHash || info.hash == current.first; +} + + /* Functions for upgrading from the pre-SQLite database. */ PathSet LocalStore::queryValidPathsOld() -- cgit 1.4.1