diff options
author | Joey Hess <joey@kitenet.net> | 2011-04-27 20:06:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-04-27 20:23:09 -0400 |
commit | e68f128a9bf46c8f4ebe51fcb3b6f63955cadd2e (patch) | |
tree | 2102052ed8289efa0e44b4f9269c423753d70983 /Content.hs | |
parent | 4381ac062fa7cec01476e84a7bd8e154efb8aacd (diff) |
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.
Diffstat (limited to 'Content.hs')
-rw-r--r-- | Content.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Content.hs b/Content.hs index dd0ea5ca1..99770f553 100644 --- a/Content.hs +++ b/Content.hs @@ -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 () |