summaryrefslogtreecommitdiff
path: root/src/Storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/Storage')
-rw-r--r--src/Storage/Internal.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Storage/Internal.hs b/src/Storage/Internal.hs
index 85742a3..402d924 100644
--- a/src/Storage/Internal.hs
+++ b/src/Storage/Internal.hs
@@ -115,8 +115,11 @@ refDigest (Ref _ dgst) = dgst
showRef :: Ref' c -> ByteString
showRef = showRefDigest . refDigest
+showRefDigestParts :: RefDigest -> (ByteString, ByteString)
+showRefDigestParts x = (BC.pack "blake2", showHex x)
+
showRefDigest :: RefDigest -> ByteString
-showRefDigest x = BC.pack "blake2#" `BC.append` showHex x
+showRefDigest = showRefDigestParts >>> \(alg, hex) -> alg <> BC.pack "#" <> hex
readRefDigest :: ByteString -> Maybe RefDigest
readRefDigest x = case BC.split '#' x of
@@ -213,7 +216,7 @@ ioLoadBytesFromStorage st dgst = loadCurrent st >>=
refPath :: FilePath -> RefDigest -> FilePath
refPath spath rdgst = intercalate "/" [spath, "objects", BC.unpack alg, pref, rest]
- where [alg, dgst] = BC.split '#' $ showRefDigest rdgst
+ where (alg, dgst) = showRefDigestParts rdgst
(pref, rest) = splitAt 2 $ BC.unpack dgst