summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Lauri Alanko <la@iki.fi>2012-01-20 06:26:04 +0200
committerGravatar Joey Hess <joey@kitenet.net>2012-01-26 01:11:57 -0400
commit6da40100c99a097401fb130b63edc05b18f61249 (patch)
tree13cf93480c2c2fc0959c998bc579ab2dd919e46b /Remote
parent9b51ec9dbf48a54184aedf3f4cd5387347d67336 (diff)
Avoid creating ~/.bup when initializing a bup remote
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Bup.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index 9b54d8c85..583358f24 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -11,6 +11,8 @@ import qualified Data.ByteString.Lazy.Char8 as L
import System.IO.Error
import qualified Data.Map as M
import System.Process
+import System.Posix.Env (getEnvironment)
+import System.Path (brackettmpdir)
import Common.Annex
import Types.Remote
@@ -83,10 +85,21 @@ bupParams :: String -> BupRepo -> [CommandParam] -> [CommandParam]
bupParams command buprepo params =
Param command : [Param "-r", Param buprepo] ++ params
+isLocal :: BupRepo -> Bool
+isLocal buprepo = not (elem ':' buprepo)
+
bup :: String -> BupRepo -> [CommandParam] -> Annex Bool
bup command buprepo params = do
showOutput -- make way for bup output
- liftIO $ boolSystem "bup" $ bupParams command buprepo params
+ liftIO action
+ where
+ action | isLocal buprepo = runBup lparams buprepo
+ | otherwise = brackettmpdir "bupXXXXXX" $ runBup rparams
+ lparams = Param command : params
+ rparams = bupParams command buprepo params
+ runBup params bupdir = do
+ env <- getEnvironment
+ boolSystemEnv "bup" params (Just (("BUP_DIR", bupdir) : env))
pipeBup :: [CommandParam] -> Maybe Handle -> Maybe Handle -> IO Bool
pipeBup params inh outh = do