2010-12-31 13:39:30 -04: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 16:02:51 -04:00
|
|
|
import Common.Annex
|
2010-12-31 13:39:30 -04:00
|
|
|
import Command
|
2011-01-16 16:05:05 -04:00
|
|
|
import CmdLine
|
2011-10-04 00:40:47 -04:00
|
|
|
import Annex.Content
|
2012-09-19 14:28:32 -04:00
|
|
|
import Utility.Rsync
|
2012-07-02 01:31:10 -04:00
|
|
|
import Logs.Transfer
|
2012-08-23 15:22:23 -04:00
|
|
|
import Command.SendKey (fieldTransfer)
|
2010-12-31 13:39:30 -04:00
|
|
|
|
2011-10-29 15:19:05 -04:00
|
|
|
def :: [Command]
|
2012-09-15 20:46:38 -04:00
|
|
|
def = [noCommit $ command "recvkey" paramKey seek
|
2010-12-31 13:39:30 -04:00
|
|
|
"runs rsync in server mode to receive content"]
|
|
|
|
|
|
|
|
seek :: [CommandSeek]
|
|
|
|
seek = [withKeys start]
|
|
|
|
|
2011-09-15 16:50:49 -04:00
|
|
|
start :: Key -> CommandStart
|
2012-07-02 01:31:10 -04:00
|
|
|
start key = ifM (inAnnex key)
|
|
|
|
( error "key is already present in annex"
|
2012-09-19 17:10:22 -04:00
|
|
|
, fieldTransfer Download key $ \_p -> do
|
2012-07-02 01:31:10 -04:00
|
|
|
ifM (getViaTmp key $ liftIO . rsyncServerReceive)
|
|
|
|
( do
|
|
|
|
-- forcibly quit after receiving one key,
|
|
|
|
-- and shutdown cleanly
|
|
|
|
_ <- shutdown True
|
2012-08-23 15:22:23 -04:00
|
|
|
return True
|
|
|
|
, return False
|
2012-07-02 01:31:10 -04:00
|
|
|
)
|
|
|
|
)
|