diff options
author | 2012-08-08 16:06:01 -0400 | |
---|---|---|
committer | 2012-08-08 16:20:24 -0400 | |
commit | 94fcd0cf59f94dd29ab171f0875bd25af65fd527 (patch) | |
tree | c89328f776d3a305cc45355471ab8fa8409aa686 /Locations.hs | |
parent | e0cd9776690c74aa1b346aa11615a75c862d7714 (diff) |
add routes to pause/start/cancel transfers
This commit includes a paydown on technical debt incurred two years ago,
when I didn't know that it was bad to make custom Read and Show instances
for types. As the routes need Read and Show for Transfer, which includes a
Key, and deriving my own Read instance of key was not practical,
I had to finally clean that up.
So the compact Key read and show functions are now file2key and key2file,
and Read and Show are now derived instances.
Changed all code that used the old instances, compiler checked.
(There were a few places, particularly in Command.Unused, and the test
suite where the Show instance continue to be used for legitimate
comparisons; ie show key_x == show key_y (though really in a bloom filter))
Diffstat (limited to 'Locations.hs')
-rw-r--r-- | Locations.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Locations.hs b/Locations.hs index cbd1e11ae..2606bef27 100644 --- a/Locations.hs +++ b/Locations.hs @@ -199,7 +199,7 @@ isLinkToAnnex s = ('/':d) `isInfixOf` s || d `isPrefixOf` s -} keyFile :: Key -> FilePath keyFile key = replace "/" "%" $ replace ":" "&c" $ - replace "%" "&s" $ replace "&" "&a" $ show key + replace "%" "&s" $ replace "&" "&a" $ key2file key {- A location to store a key on the filesystem. A directory hash is used, - to protect against filesystems that dislike having many items in a @@ -220,7 +220,7 @@ keyPaths key = map (keyPath key) annexHashes {- Reverses keyFile, converting a filename fragment (ie, the basename of - the symlink target) into a key. -} fileKey :: FilePath -> Maybe Key -fileKey file = readKey $ +fileKey file = file2key $ replace "&a" "&" $ replace "&s" "%" $ replace "&c" ":" $ replace "%" "/" file @@ -242,12 +242,12 @@ hashDirMixed :: Hasher hashDirMixed k = addTrailingPathSeparator $ take 2 dir </> drop 2 dir where dir = take 4 $ display_32bits_as_dir =<< [a,b,c,d] - ABCD (a,b,c,d) = md5 $ encodeFilePath $ show k + ABCD (a,b,c,d) = md5 $ encodeFilePath $ key2file k hashDirLower :: Hasher hashDirLower k = addTrailingPathSeparator $ take 3 dir </> drop 3 dir where - dir = take 6 $ md5s $ encodeFilePath $ show k + dir = take 6 $ md5s $ encodeFilePath $ key2file k {- modified version of display_32bits_as_hex from Data.Hash.MD5 - Copyright (C) 2001 Ian Lynagh |