
* unannex, uninit: Avoid committing after every file is unannexed, for massive speedup. * --notify-finish switch will cause desktop notifications after each file upload/download/drop completes (using the dbus Desktop Notifications Specification) * --notify-start switch will show desktop notifications when each file upload/download starts. * webapp: Automatically install Nautilus integration scripts to get and drop files. * tahoe: Pass -d parameter before subcommand; putting it after the subcommand no longer works with tahoe-lafs version 1.10. (Thanks, Alberto Berti) * forget --drop-dead: Avoid removing the dead remote from the trust.log, so that if git remotes for it still exist anywhere, git annex info will still know it's dead and not show it. * git-annex-shell: Make configlist automatically initialize a remote git repository, as long as a git-annex branch has been pushed to it, to simplify setup of remote git repositories, including via gitolite. * add --include-dotfiles: New option, perhaps useful for backups. * Version 5.20140227 broke creation of glacier repositories, not including the datacenter and vault in their configuration. This bug is fixed, but glacier repositories set up with the broken version of git-annex need to have the datacenter and vault set in order to be usable. This can be done using git annex enableremote to add the missing settings. For details, see http://git-annex.branchable.com/bugs/problems_with_glacier/ * Added required content configuration. * assistant: Improve ssh authorized keys line generated in local pairing or for a remote ssh server to set environment variables in an alternative way that works with the non-POSIX fish shell, as well as POSIX shells. # imported from the archive
87 lines
2.4 KiB
Haskell
87 lines
2.4 KiB
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.RecvKey where
|
|
|
|
import Common.Annex
|
|
import Command
|
|
import CmdLine
|
|
import Annex.Content
|
|
import Annex
|
|
import Utility.Rsync
|
|
import Logs.Transfer
|
|
import Command.SendKey (fieldTransfer)
|
|
import qualified CmdLine.GitAnnexShell.Fields as Fields
|
|
import qualified Types.Key
|
|
import qualified Types.Backend
|
|
import qualified Backend
|
|
|
|
def :: [Command]
|
|
def = [noCommit $ command "recvkey" paramKey seek
|
|
SectionPlumbing "runs rsync in server mode to receive content"]
|
|
|
|
seek :: CommandSeek
|
|
seek = withKeys start
|
|
|
|
start :: Key -> CommandStart
|
|
start key = ifM (inAnnex key)
|
|
( error "key is already present in annex"
|
|
, fieldTransfer Download key $ \_p ->
|
|
ifM (getViaTmp key go)
|
|
( do
|
|
-- forcibly quit after receiving one key,
|
|
-- and shutdown cleanly
|
|
_ <- shutdown True
|
|
return True
|
|
, return False
|
|
)
|
|
)
|
|
where
|
|
go tmp = do
|
|
opts <- filterRsyncSafeOptions . maybe [] words
|
|
<$> getField "RsyncOptions"
|
|
ok <- liftIO $ rsyncServerReceive (map Param opts) tmp
|
|
|
|
-- The file could have been received with permissions that
|
|
-- do not allow reading it, so this is done before the
|
|
-- directcheck.
|
|
freezeContent tmp
|
|
|
|
if ok
|
|
then ifM (isJust <$> Fields.getField Fields.direct)
|
|
( directcheck tmp
|
|
, return True
|
|
)
|
|
else return False
|
|
{- If the sending repository uses direct mode, the file
|
|
- it sends could be modified as it's sending it. So check
|
|
- that the right size file was received, and that the key/value
|
|
- Backend is happy with it. -}
|
|
directcheck tmp = do
|
|
oksize <- case Types.Key.keySize key of
|
|
Nothing -> return True
|
|
Just size -> do
|
|
size' <- fromIntegral . fileSize
|
|
<$> liftIO (getFileStatus tmp)
|
|
return $ size == size'
|
|
if oksize
|
|
then case Backend.maybeLookupBackendName (Types.Key.keyBackendName key) of
|
|
Nothing -> do
|
|
warning "recvkey: received key from direct mode repository using unknown backend; cannot check; discarding"
|
|
return False
|
|
Just backend -> maybe (return True) runfsck
|
|
(Types.Backend.fsckKey backend)
|
|
else do
|
|
warning "recvkey: received key with wrong size; discarding"
|
|
return False
|
|
where
|
|
runfsck check = ifM (check key tmp)
|
|
( return True
|
|
, do
|
|
warning "recvkey: received key from direct mode repository seems to have changed as it was transferred; discarding"
|
|
return False
|
|
)
|