rsync special remote

Fully tested and working, including resuming and encryption. (Though not
resuming when sending *with* encryption; gpg doesn't produce identical
output each time.)

Uses same layout as the directory special remote and the .git/annex/objects/
directory.
This commit is contained in:
Joey Hess 2011-04-27 20:06:07 -04:00
parent 4381ac062f
commit e68f128a9b
11 changed files with 265 additions and 19 deletions

View file

@ -12,6 +12,7 @@ module Content (
logStatusFor,
getViaTmp,
getViaTmpUnchecked,
withTmp,
checkDiskSpace,
preventWrite,
allowWrite,
@ -127,6 +128,17 @@ getViaTmpUnchecked key action = do
-- to resume its transfer
return False
{- Creates a temp file, runs an action on it, and cleans up the temp file. -}
withTmp :: Key -> (FilePath -> Annex a) -> Annex a
withTmp key action = do
g <- Annex.gitRepo
let tmp = gitAnnexTmpLocation g key
liftIO $ createDirectoryIfMissing True (parentDir tmp)
res <- action tmp
tmp_exists <- liftIO $ doesFileExist tmp
when tmp_exists $ liftIO $ removeFile tmp
return res
{- Checks that there is disk space available to store a given key,
- throwing an error if not. -}
checkDiskSpace :: Key -> Annex ()