2010-12-31 17:39:30 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.RecvKey where
|
|
|
|
|
2011-10-05 20:02:51 +00:00
|
|
|
import Common.Annex
|
2010-12-31 17:39:30 +00:00
|
|
|
import Command
|
2011-01-16 20:05:05 +00:00
|
|
|
import CmdLine
|
2011-10-04 04:40:47 +00:00
|
|
|
import Annex.Content
|
2011-07-06 00:24:10 +00:00
|
|
|
import Utility.RsyncFile
|
2012-07-02 05:31:10 +00:00
|
|
|
import Logs.Transfer
|
2010-12-31 17:39:30 +00:00
|
|
|
|
2011-10-29 19:19:05 +00:00
|
|
|
def :: [Command]
|
2012-02-14 16:40:40 +00:00
|
|
|
def = [oneShot $ command "recvkey" paramKey seek
|
2010-12-31 17:39:30 +00:00
|
|
|
"runs rsync in server mode to receive content"]
|
|
|
|
|
|
|
|
seek :: [CommandSeek]
|
|
|
|
seek = [withKeys start]
|
|
|
|
|
2011-09-15 20:50:49 +00:00
|
|
|
start :: Key -> CommandStart
|
2012-07-02 05:31:10 +00:00
|
|
|
start key = ifM (inAnnex key)
|
|
|
|
( error "key is already present in annex"
|
|
|
|
, fieldTransfer Download key $ do
|
|
|
|
ifM (getViaTmp key $ liftIO . rsyncServerReceive)
|
|
|
|
( do
|
|
|
|
-- forcibly quit after receiving one key,
|
|
|
|
-- and shutdown cleanly
|
|
|
|
_ <- shutdown True
|
|
|
|
liftIO exitSuccess
|
|
|
|
, liftIO exitFailure
|
|
|
|
)
|
|
|
|
)
|