2010-11-02 23:04:24 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Get where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import qualified Backend
|
|
|
|
import Types
|
2011-01-16 20:05:05 +00:00
|
|
|
import Content
|
2010-11-08 19:15:21 +00:00
|
|
|
import Messages
|
2010-11-02 23:04:24 +00:00
|
|
|
|
2010-12-30 19:06:26 +00:00
|
|
|
command :: [Command]
|
2011-03-19 22:58:49 +00:00
|
|
|
command = [repoCommand "get" paramPath seek
|
2010-12-30 19:06:26 +00:00
|
|
|
"make content of annexed files available"]
|
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
seek :: [CommandSeek]
|
2010-11-11 22:54:52 +00:00
|
|
|
seek = [withFilesInGit start]
|
|
|
|
|
2010-11-02 23:04:24 +00:00
|
|
|
{- Gets an annexed file from one of the backends. -}
|
2010-12-30 18:19:16 +00:00
|
|
|
start :: CommandStartString
|
2010-11-02 23:04:24 +00:00
|
|
|
start file = isAnnexed file $ \(key, backend) -> do
|
|
|
|
inannex <- inAnnex key
|
2010-11-22 21:51:55 +00:00
|
|
|
if inannex
|
2011-05-15 06:02:46 +00:00
|
|
|
then stop
|
2010-11-02 23:04:24 +00:00
|
|
|
else do
|
|
|
|
showStart "get" file
|
2011-05-15 06:02:46 +00:00
|
|
|
next $ perform key backend
|
2010-11-02 23:04:24 +00:00
|
|
|
|
2011-01-26 01:02:34 +00:00
|
|
|
perform :: Key -> Backend Annex -> CommandPerform
|
2010-11-02 23:04:24 +00:00
|
|
|
perform key backend = do
|
|
|
|
ok <- getViaTmp key (Backend.retrieveKeyFile backend key)
|
2010-11-22 21:51:55 +00:00
|
|
|
if ok
|
2011-05-15 06:02:46 +00:00
|
|
|
then next $ return True -- no cleanup needed
|
|
|
|
else stop
|