diff options
-rw-r--r-- | Locations.hs | 4 | ||||
-rw-r--r-- | Test.hs | 1 | ||||
-rw-r--r-- | Types/Key.hs | 10 | ||||
-rw-r--r-- | doc/bugs/git-annex:_status:_1_failed.mdwn | 9 |
4 files changed, 21 insertions, 3 deletions
diff --git a/Locations.hs b/Locations.hs index 47607c577..b96f58d5f 100644 --- a/Locations.hs +++ b/Locations.hs @@ -346,7 +346,9 @@ fileKey file = file2key $ {- for quickcheck -} prop_idempotent_fileKey :: String -> Bool -prop_idempotent_fileKey s = Just k == fileKey (keyFile k) +prop_idempotent_fileKey s + | null s = True -- it's not legal for a key to have no keyName + | otherwise= Just k == fileKey (keyFile k) where k = stubKey { keyName = s, keyBackendName = "test" } @@ -119,6 +119,7 @@ quickcheck = , check "prop_idempotent_deencode" Utility.Format.prop_idempotent_deencode , check "prop_idempotent_fileKey" Locations.prop_idempotent_fileKey , check "prop_idempotent_key_encode" Types.Key.prop_idempotent_key_encode + , check "prop_idempotent_key_decode" Types.Key.prop_idempotent_key_decode , check "prop_idempotent_shellEscape" Utility.SafeCommand.prop_idempotent_shellEscape , check "prop_idempotent_shellEscape_multiword" Utility.SafeCommand.prop_idempotent_shellEscape_multiword , check "prop_logs_sane" Logs.prop_logs_sane diff --git a/Types/Key.hs b/Types/Key.hs index 2ddb3f50e..f900ece2b 100644 --- a/Types/Key.hs +++ b/Types/Key.hs @@ -14,7 +14,8 @@ module Types.Key ( key2file, file2key, - prop_idempotent_key_encode + prop_idempotent_key_encode, + prop_idempotent_key_decode ) where import System.Posix.Types @@ -59,7 +60,7 @@ key2file Key { keyBackendName = b, keySize = s, keyMtime = m, keyName = n } = _ ?: _ = "" file2key :: FilePath -> Maybe Key -file2key s = if key == Just stubKey then Nothing else key +file2key s = if key == Just stubKey || (keyName <$> key) == Just "" then Nothing else key where key = startbackend stubKey s @@ -88,3 +89,8 @@ instance Arbitrary Key where 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) diff --git a/doc/bugs/git-annex:_status:_1_failed.mdwn b/doc/bugs/git-annex:_status:_1_failed.mdwn index 31089b53b..65f00469c 100644 --- a/doc/bugs/git-annex:_status:_1_failed.mdwn +++ b/doc/bugs/git-annex:_status:_1_failed.mdwn @@ -14,3 +14,12 @@ i get : how could i fix this issue ? many thanks for help + +> [[done]]; I managed to reproduce this bug by making a temp file named +> ".git/annex/tmp/foo-", or indeed with any dash in it. This is enough +> to make git-annex think it's a key, but badly formed enough that +> it fails trying to use that key. Fixed to ignore such non-key files. +> +> I'm unsure why `.git/annex/tmp` would have such files in it. +> Perhaps the assistant was running, but crashed while adding files? +> --[[Joey]] |