From 2b9e3d5ca89f88fbcae237270e95c592e3ce3bc1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 25 Jul 2014 16:09:23 -0400 Subject: use same hash directories for chunked key as are used for its parent This avoids a proliferation of hash directories when using new-style chunking, and should improve performance since chunks are accessed in sequence and so should have a common locality. Of course, when a chunked key is encrypted, its hash directories have no relation to the parent key. This commit was sponsored by Christian Kellermann. --- Types/Key.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Types') diff --git a/Types/Key.hs b/Types/Key.hs index 90f66f23e..3015b1e86 100644 --- a/Types/Key.hs +++ b/Types/Key.hs @@ -13,6 +13,8 @@ module Types.Key ( stubKey, key2file, file2key, + isChunkKey, + nonChunkKey, prop_idempotent_key_encode, prop_idempotent_key_decode @@ -47,6 +49,16 @@ stubKey = Key , keyChunkNum = Nothing } +isChunkKey :: Key -> Bool +isChunkKey k = isJust (keyChunkSize k) && isJust (keyChunkNum k) + +-- Gets the parent of a chunk key. +nonChunkKey :: Key -> Key +nonChunkKey k = k + { keyChunkSize = Nothing + , keyChunkNum = Nothing + } + fieldSep :: Char fieldSep = '-' -- cgit v1.2.3