1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-27 12:41:00 +01:00

downscaled to 1 repos per statePath

This commit is contained in:
Wouter den Breejen 2007-07-08 22:40:16 +00:00
parent cce4156232
commit 9f00b42f38
19 changed files with 218 additions and 399 deletions

View file

@ -153,18 +153,11 @@ void checkStatePath(const Derivation & drv)
Error(format("The statepath from the Derivation does not match the recalculated statepath, are u trying to spoof the statepath?"));
}
void calculateStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier, Path & rootPath, Path & fullPath)
void calculateStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier, Path & path)
{
//This is a little trick: we could use the same hash as the statepath, but we change it so the repository also gets a unique scannable hash
Hash hash = hashString(htSHA256, statePath);
//We also hash repository subfolders the prevent collisions
if(subfolder.length() == 0)
throw Error(format("Cannot create a repository for a subfolder without a name"));
string hash_subfolder = type + ":sha256:" + printHash(hash) + ":" + subfolder;
string subfolder2 = printHash32(compressHash(hashString(htSHA256, hash_subfolder), 20)) + "-" + subfolder;
string suffix_stateIdentifier = stateIdentifier;
if(suffix_stateIdentifier != "")
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
@ -176,28 +169,18 @@ void calculateStateReposPath(const string & type, const Path statePath, const st
checkStoreName(suffix);
checkStoreName(stateIdentifier);
rootPath = nixStoreStateRepos + "/"
path = nixStoreStateRepos + "/"
+ printHash32(compressHash(hashString(htSHA256, s), 20))
+ "-" + suffix + suffix_stateIdentifier;
fullPath = rootPath + "/" + subfolder2;
+ "-" + suffix + suffix_stateIdentifier + "/";
}
Path getStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier)
Path getStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
{
Path fullPath;
Path rootPath;
calculateStateReposPath(type, statePath, subfolder, suffix, stateIdentifier, rootPath, fullPath);
return fullPath;
Path path;
calculateStateReposPath(type, statePath, suffix, stateIdentifier, path);
return path;
}
Path getStateReposRootPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
{
Path fullPath;
Path rootPath;
calculateStateReposPath(type, statePath, "/", suffix, stateIdentifier, rootPath, fullPath);
return rootPath;
}
Path makeFixedOutputPath(bool recursive,
string hashAlgo, Hash hash, string name)