reorder repo parameters last
Many functions took the repo as their first parameter. Changing it consistently to be the last parameter allows doing some useful things with currying, that reduce boilerplate. In particular, g <- gitRepo is almost never needed now, instead use inRepo to run an IO action in the repo, and fromRepo to get a value from the repo. This also provides more opportunities to use monadic and applicative combinators.
This commit is contained in:
parent
2ff8915365
commit
bf460a0a98
46 changed files with 338 additions and 390 deletions
|
@ -42,14 +42,13 @@ upgradableKey key = isNothing $ Types.Key.keySize key
|
|||
|
||||
perform :: FilePath -> Key -> Backend Annex -> CommandPerform
|
||||
perform file oldkey newbackend = do
|
||||
g <- gitRepo
|
||||
|
||||
-- Store the old backend's cached key in the new backend
|
||||
-- (the file can't be stored as usual, because it's already a symlink).
|
||||
-- The old backend's key is not dropped from it, because there may
|
||||
-- be other files still pointing at that key.
|
||||
let src = gitAnnexLocation g oldkey
|
||||
let tmpfile = gitAnnexTmpDir g </> takeFileName file
|
||||
src <- fromRepo $ gitAnnexLocation oldkey
|
||||
tmp <- fromRepo $ gitAnnexTmpDir
|
||||
let tmpfile = tmp </> takeFileName file
|
||||
liftIO $ createLink src tmpfile
|
||||
k <- Backend.genKey tmpfile $ Just newbackend
|
||||
liftIO $ cleantmp tmpfile
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue