diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-11-26 20:26:22 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-11-26 20:26:22 +0100 |
commit | ec5e7b44ff1ce14eb930948df1b89f07abbf16f9 (patch) | |
tree | 34732f8d0b72af4f60e856dcd9bdaf49671d879b /src | |
parent | 96e1c39bb71327f49a7955f945dd95aec66f5ef1 (diff) |
Simplify
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/local-store.cc | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 0d44665b0..60e7bb7af 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1244,30 +1244,24 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair) printInfo("checking link hashes..."); - AutoCloseDir dir(opendir(linksDir.c_str())); - if (!dir) throw SysError(format("opening directory '%1%'") % linksDir); - - struct dirent * dirent; - while (errno = 0, dirent = readdir(dir.get())) { /* sic */ - checkInterrupt(); - if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0) continue; - Path linkPath = linksDir + "/" + dirent->d_name; + for (auto & link : readDirectory(linksDir)) { + printMsg(lvlTalkative, "checking contents of '%s'", link.name); + Path linkPath = linksDir + "/" + link.name; string hash = hashPath(htSHA256, linkPath).first.to_string(Base32, false); - if (hash != dirent->d_name) { - printError(format("link '%1%' was modified! " - "expected hash '%2%', got '%3%'") - % linkPath % dirent->d_name % hash); + if (hash != link.name) { + printError( + "link '%s' was modified! expected hash '%s', got '%s'", + linkPath, link.name, hash); if (repair) { if (unlink(linkPath.c_str()) == 0) - printError(format("Removed link '%1%'") % linkPath); + printError("removed link '%s'", linkPath); else - throw SysError(format("removing corrupt link '%1%'") % linkPath); + throw SysError("removing corrupt link '%s'", linkPath); } else { errors = true; } } } - if (errno) throw SysError(format("reading directory '%1%'") % linksDir); printInfo("checking store hashes..."); |