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
|
|
|
|
|
|
|
|
import Control.Monad.State (liftIO)
|
|
|
|
import System.Exit
|
|
|
|
|
|
|
|
import Command
|
2011-01-16 20:05:05 +00:00
|
|
|
import CmdLine
|
|
|
|
import Content
|
2011-07-06 00:24:10 +00:00
|
|
|
import Utility.RsyncFile
|
2011-08-22 20:14:12 +00:00
|
|
|
import Utility.Conditional
|
2010-12-31 17:39:30 +00:00
|
|
|
|
|
|
|
command :: [Command]
|
2011-03-19 22:58:49 +00:00
|
|
|
command = [repoCommand "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-03-16 02:42:34 +00:00
|
|
|
start :: CommandStartKey
|
|
|
|
start key = do
|
2011-05-17 07:10:13 +00:00
|
|
|
whenM (inAnnex key) $ error "key is already present in annex"
|
2010-12-31 17:39:30 +00:00
|
|
|
|
|
|
|
ok <- getViaTmp key (liftIO . rsyncServerReceive)
|
|
|
|
if ok
|
2010-12-31 23:09:17 +00:00
|
|
|
then do
|
|
|
|
-- forcibly quit after receiving one key,
|
|
|
|
-- and shutdown cleanly so queued git commands run
|
2011-01-30 03:32:32 +00:00
|
|
|
_ <- shutdown
|
2010-12-31 23:09:17 +00:00
|
|
|
liftIO exitSuccess
|
2010-12-31 17:39:30 +00:00
|
|
|
else liftIO exitFailure
|