summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2026-05-30 15:16:57 +0200
committerLudovic Courtès <ludo@gnu.org>2026-08-17 16:47:36 +0200
commit27f40fad8064064d7c9d3ce5a126a331b62716e1 (patch)
tree00b02d3dedf6f83714f6ddd01f55f11a1aee3ec5
parentd04d7d9be525aaf2d55792b172b051ec5a539eed (diff)
daemon: Separate out ‘textTypeWithReferences’.
* nix/libstore/store-api.cc (textTypeWithReferences): New function. (computeStorePathForText): Use it. Change-Id: I9d82ac04619d736ce737dec745416396b7b18751 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--nix/libstore/store-api.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/nix/libstore/store-api.cc b/nix/libstore/store-api.cc
index 6445209652e..feabc821678 100644
--- a/nix/libstore/store-api.cc
+++ b/nix/libstore/store-api.cc
@@ -236,18 +236,25 @@ Path makeFixedOutputPath(bool recursive,
236} 236}
237 237
238 238
239Path computeStorePathForText(const string & name, const string & s, 239/* Return the 'type' part of a text store item with the given REFERENCES. */
240 const PathSet & references) 240static string textTypeWithReferences(const PathSet & references)
241{ 241{
242 Hash hash = hashString(htSHA256, s);
243 /* Stuff the references (if any) into the type. This is a bit 242 /* Stuff the references (if any) into the type. This is a bit
244 hacky, but we can't put them in `s' since that would be 243 hacky, but we can't put them in the file content since that would be
245 ambiguous. */ 244 ambiguous. */
246 string type = "text"; 245 string type = "text";
247 for (const auto& i : references) { 246 for (const auto& i : references) {
248 type += ":"; 247 type += ":";
249 type += i; 248 type += i;
250 } 249 }
250 return type;
251}
252
253Path computeStorePathForText(const string & name, const string & s,
254 const PathSet & references)
255{
256 Hash hash = hashString(htSHA256, s);
257 string type = textTypeWithReferences(references);
251 return makeStorePath(type, hash, name); 258 return makeStorePath(type, hash, name);
252} 259}
253 260