summaryrefslogtreecommitdiff
path: root/Types/Key.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-11 15:41:31 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-11 15:41:31 -0400
commit5219b32e26277d355784b9d92aa34f7730040624 (patch)
tree8f436de150ed218e0d8073956d3d6771da259cf1 /Types/Key.hs
parent14bbc9b7214c58076cebc82e749a557e8b725db9 (diff)
file2key should return Nothing if the backend is empty
This failed a quickcheck test on the filename "-a"
Diffstat (limited to 'Types/Key.hs')
-rw-r--r--Types/Key.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/Types/Key.hs b/Types/Key.hs
index f900ece2b..598d5ed20 100644
--- a/Types/Key.hs
+++ b/Types/Key.hs
@@ -60,7 +60,9 @@ key2file Key { keyBackendName = b, keySize = s, keyMtime = m, keyName = n } =
_ ?: _ = ""
file2key :: FilePath -> Maybe Key
-file2key s = if key == Just stubKey || (keyName <$> key) == Just "" then Nothing else key
+file2key s
+ | key == Just stubKey || (keyName <$> key) == Just "" || (keyBackendName <$> key) == Just "" = Nothing
+ | otherwise = key
where
key = startbackend stubKey s
@@ -91,6 +93,4 @@ prop_idempotent_key_encode :: Key -> Bool
prop_idempotent_key_encode k = Just k == (file2key . key2file) k
prop_idempotent_key_decode :: FilePath -> Bool
-prop_idempotent_key_decode f
- | null f = True -- skip illegal empty filename
- | otherwise = maybe True (\k -> key2file k == f) (file2key f)
+prop_idempotent_key_decode f = maybe True (\k -> key2file k == f) (file2key f)