1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 09:19:36 +01:00

Create new file-hash files

This commit is contained in:
Carlo Nucera 2020-06-01 17:32:27 -04:00
parent 0cb67ecbd3
commit 0e9438b6d3
8 changed files with 64 additions and 52 deletions

27
src/libstore/file-hash.cc Normal file
View file

@ -0,0 +1,27 @@
#include "file-hash.hh"
namespace nix {
std::string FileSystemHash::printMethodAlgo() const {
return makeFileIngestionPrefix(method) + printHashType(hash.type);
}
std::string makeFileIngestionPrefix(const FileIngestionMethod m) {
switch (m) {
case FileIngestionMethod::Flat:
return "";
case FileIngestionMethod::Recursive:
return "r:";
default:
throw Error("impossible, caught both cases");
}
}
std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash)
{
return "fixed:"
+ makeFileIngestionPrefix(method)
+ hash.to_string();
}
}