summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Bup.hs21
-rw-r--r--Remote/Directory.hs23
-rw-r--r--Remote/Git.hs27
-rw-r--r--Remote/Helper/Encryptable.hs4
-rw-r--r--Remote/Helper/Special.hs11
-rw-r--r--Remote/Hook.hs20
-rw-r--r--Remote/Rsync.hs24
-rw-r--r--Remote/S3real.hs16
-rw-r--r--Remote/Web.hs12
9 files changed, 36 insertions, 122 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index 29c7a0419..958831019 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -8,30 +8,15 @@
module Remote.Bup (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
-import System.IO
import System.IO.Error
-import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
-import Control.Monad (when)
-import Control.Monad.State (liftIO)
import System.Process
-import System.Exit
-import System.FilePath
-import Data.Maybe
-import Data.List.Utils
-import System.Cmd.Utils
-import Types
+import AnnexCommon
import Types.Remote
import qualified Git
-import qualified Annex
import UUID
-import Locations
import Config
-import Utility
-import Utility.Conditional
-import Utility.SafeCommand
-import Messages
import Utility.Ssh
import Remote.Helper.Special
import Remote.Helper.Encryptable
@@ -118,14 +103,14 @@ bupSplitParams r buprepo k src = do
store :: Git.Repo -> BupRepo -> Key -> Annex Bool
store r buprepo k = do
- g <- Annex.gitRepo
+ g <- gitRepo
let src = gitAnnexLocation g k
params <- bupSplitParams r buprepo k (File src)
liftIO $ boolSystem "bup" params
storeEncrypted :: Git.Repo -> BupRepo -> (Cipher, Key) -> Key -> Annex Bool
storeEncrypted r buprepo (cipher, enck) k = do
- g <- Annex.gitRepo
+ g <- gitRepo
let src = gitAnnexLocation g k
params <- bupSplitParams r buprepo enck (Param "-")
liftIO $ catchBool $
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index 18835c5de..664f8ca5f 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -9,25 +9,14 @@ module Remote.Directory (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
import System.IO.Error
-import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
-import Control.Monad (when)
-import Control.Monad.State (liftIO)
-import System.Directory hiding (copyFile)
-import System.FilePath
-import Data.Maybe
-import Types
+import AnnexCommon
+import Utility.CopyFile
import Types.Remote
import qualified Git
-import qualified Annex
import UUID
-import Locations
-import Utility.CopyFile
import Config
-import Utility
-import Utility.Conditional
-import Utility.Path
import Utility.FileMode
import Remote.Helper.Special
import Remote.Helper.Encryptable
@@ -82,14 +71,14 @@ dirKey d k = d </> hashDirMixed k </> f </> f
store :: FilePath -> Key -> Annex Bool
store d k = do
- g <- Annex.gitRepo
+ g <- gitRepo
let src = gitAnnexLocation g k
let dest = dirKey d k
- liftIO $ catchBool $ storeHelper dest $ copyFile src dest
+ liftIO $ catchBool $ storeHelper dest $ copyFileExternal src dest
storeEncrypted :: FilePath -> (Cipher, Key) -> Key -> Annex Bool
storeEncrypted d (cipher, enck) k = do
- g <- Annex.gitRepo
+ g <- gitRepo
let src = gitAnnexLocation g k
let dest = dirKey d enck
liftIO $ catchBool $ storeHelper dest $ encrypt src dest
@@ -110,7 +99,7 @@ storeHelper dest a = do
return ok
retrieve :: FilePath -> Key -> FilePath -> Annex Bool
-retrieve d k f = liftIO $ copyFile (dirKey d k) f
+retrieve d k f = liftIO $ copyFileExternal (dirKey d k) f
retrieveEncrypted :: FilePath -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted d (cipher, enck) f =
diff --git a/Remote/Git.hs b/Remote/Git.hs
index d50899c67..a457c5905 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -8,26 +8,17 @@
module Remote.Git (remote) where
import Control.Exception.Extensible
-import Control.Monad.State (liftIO)
import qualified Data.Map as M
-import System.Cmd.Utils
-import System.Posix.Files
-import System.IO
-import Types
+import AnnexCommon
+import Utility.CopyFile
+import Utility.RsyncFile
+import Utility.Ssh
import Types.Remote
import qualified Git
import qualified Annex
-import Locations
import UUID
-import Utility
import qualified Content
-import Messages
-import Utility.CopyFile
-import Utility.RsyncFile
-import Utility.Ssh
-import Utility.SafeCommand
-import Utility.Path
import qualified Utility.Url as Url
import Config
import Init
@@ -42,7 +33,7 @@ remote = RemoteType {
list :: Annex [Git.Repo]
list = do
- g <- Annex.gitRepo
+ g <- gitRepo
return $ Git.remotes g
gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex (Remote Annex)
@@ -109,7 +100,7 @@ tryGitConfigRead r
store a = do
r' <- a
- g <- Annex.gitRepo
+ g <- gitRepo
let l = Git.remotes g
let g' = Git.remotesAdd g $ exchange l r'
Annex.changeState $ \s -> s { Annex.repo = g' }
@@ -169,7 +160,7 @@ copyFromRemote r key file
copyToRemote :: Git.Repo -> Key -> Annex Bool
copyToRemote r key
| not $ Git.repoIsUrl r = do
- g <- Annex.gitRepo
+ g <- gitRepo
let keysrc = gitAnnexLocation g key
-- run copy from perspective of remote
liftIO $ onLocal r $ do
@@ -178,7 +169,7 @@ copyToRemote r key
Content.saveState
return ok
| Git.repoIsSsh r = do
- g <- Annex.gitRepo
+ g <- gitRepo
let keysrc = gitAnnexLocation g key
rsyncHelper =<< rsyncParamsRemote r False key keysrc
| otherwise = error "copying to non-ssh repo not supported"
@@ -200,7 +191,7 @@ rsyncOrCopyFile r src dest = do
ss <- liftIO $ getFileStatus $ parentDir src
ds <- liftIO $ getFileStatus $ parentDir dest
if deviceID ss == deviceID ds
- then liftIO $ copyFile src dest
+ then liftIO $ copyFileExternal src dest
else do
params <- rsyncParams r
rsyncHelper $ params ++ [Param src, Param dest]
diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs
index 04041c655..42503e4d4 100644
--- a/Remote/Helper/Encryptable.hs
+++ b/Remote/Helper/Encryptable.hs
@@ -8,13 +8,11 @@
module Remote.Helper.Encryptable where
import qualified Data.Map as M
-import Control.Monad.State (liftIO)
-import Types
+import AnnexCommon
import Types.Remote
import Crypto
import qualified Annex
-import Messages
import Config
{- Encryption setup for a remote. The user must specify whether to use
diff --git a/Remote/Helper/Special.hs b/Remote/Helper/Special.hs
index b842588c0..905db04c5 100644
--- a/Remote/Helper/Special.hs
+++ b/Remote/Helper/Special.hs
@@ -8,16 +8,11 @@
module Remote.Helper.Special where
import qualified Data.Map as M
-import Data.Maybe
-import Data.String.Utils
-import Control.Monad.State (liftIO)
-import Types
+import AnnexCommon
import Types.Remote
import qualified Git
-import qualified Annex
import UUID
-import Utility.SafeCommand
{- Special remotes don't have a configured url, so Git.Repo does not
- automatically generate remotes for them. This looks for a different
@@ -25,7 +20,7 @@ import Utility.SafeCommand
-}
findSpecialRemotes :: String -> Annex [Git.Repo]
findSpecialRemotes s = do
- g <- Annex.gitRepo
+ g <- gitRepo
return $ map construct $ remotepairs g
where
remotepairs r = M.toList $ M.filterWithKey match $ Git.configMap r
@@ -35,7 +30,7 @@ findSpecialRemotes s = do
{- Sets up configuration for a special remote in .git/config. -}
gitConfigSpecialRemote :: UUID -> RemoteConfig -> String -> String -> Annex ()
gitConfigSpecialRemote u c k v = do
- g <- Annex.gitRepo
+ g <- gitRepo
liftIO $ do
Git.run g "config" [Param (configsetting $ "annex-"++k), Param v]
Git.run g "config" [Param (configsetting "annex-uuid"), Param u]
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index aaeb702c7..3bbda1924 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -8,31 +8,19 @@
module Remote.Hook (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
-import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
-import Control.Monad.State (liftIO)
-import System.FilePath
-import System.Posix.Process hiding (executeFile)
-import System.Posix.IO
-import System.IO
import System.IO.Error (try)
import System.Exit
-import Data.Maybe
-import Types
+import AnnexCommon
import Types.Remote
import qualified Git
-import qualified Annex
import UUID
-import Locations
import Config
import Content
-import Utility
-import Utility.SafeCommand
import Remote.Helper.Special
import Remote.Helper.Encryptable
import Crypto
-import Messages
remote :: RemoteType Annex
remote = RemoteType {
@@ -86,7 +74,7 @@ hookEnv k f = Just $ fileenv f ++ keyenv
lookupHook :: String -> String -> Annex (Maybe String)
lookupHook hooktype hook =do
- g <- Annex.gitRepo
+ g <- gitRepo
command <- getConfig g hookname ""
if null command
then do
@@ -111,12 +99,12 @@ runHook hooktype hook k f a = maybe (return False) run =<< lookupHook hooktype h
store :: String -> Key -> Annex Bool
store h k = do
- g <- Annex.gitRepo
+ g <- gitRepo
runHook h "store" k (Just $ gitAnnexLocation g k) $ return True
storeEncrypted :: String -> (Cipher, Key) -> Key -> Annex Bool
storeEncrypted h (cipher, enck) k = withTmp enck $ \tmp -> do
- g <- Annex.gitRepo
+ g <- gitRepo
let f = gitAnnexLocation g k
liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s
runHook h "store" enck (Just tmp) $ return True
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index 9d2d7ddcf..6a1c297c5 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -8,32 +8,18 @@
module Remote.Rsync (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
-import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
-import Control.Monad.State (liftIO)
-import System.FilePath
-import System.Directory
-import System.Posix.Files
-import System.Posix.Process
-import Data.Maybe
-
-import Types
+
+import AnnexCommon
import Types.Remote
import qualified Git
-import qualified Annex
import UUID
-import Locations
import Config
import Content
-import Utility
-import Utility.Conditional
import Remote.Helper.Special
import Remote.Helper.Encryptable
import Crypto
-import Messages
import Utility.RsyncFile
-import Utility.SafeCommand
-import Utility.Path
type RsyncUrl = String
@@ -106,12 +92,12 @@ rsyncKeyDir o k = rsyncUrl o </> hashDirMixed k </> shellEscape (keyFile k)
store :: RsyncOpts -> Key -> Annex Bool
store o k = do
- g <- Annex.gitRepo
+ g <- gitRepo
rsyncSend o k (gitAnnexLocation g k)
storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> Annex Bool
storeEncrypted o (cipher, enck) k = withTmp enck $ \tmp -> do
- g <- Annex.gitRepo
+ g <- gitRepo
let f = gitAnnexLocation g k
liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s
rsyncSend o enck tmp
@@ -166,7 +152,7 @@ partialParams = Params "--no-inplace --partial --partial-dir=.rsync-partial"
- up trees for rsync. -}
withRsyncScratchDir :: (FilePath -> Annex Bool) -> Annex Bool
withRsyncScratchDir a = do
- g <- Annex.gitRepo
+ g <- gitRepo
pid <- liftIO getProcessID
let tmp = gitAnnexTmpDir g </> "rsynctmp" </> show pid
nuke tmp
diff --git a/Remote/S3real.hs b/Remote/S3real.hs
index cafa4f15a..b2ea4b0c8 100644
--- a/Remote/S3real.hs
+++ b/Remote/S3real.hs
@@ -7,31 +7,21 @@
module Remote.S3 (remote) where
-import Control.Exception.Extensible (IOException)
import Network.AWS.AWSConnection
import Network.AWS.S3Object
import Network.AWS.S3Bucket hiding (size)
import Network.AWS.AWSResult
import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.Map as M
-import Data.Maybe
-import Data.List
import Data.Char
-import Data.String.Utils
-import Control.Monad (when)
-import Control.Monad.State (liftIO)
import System.Environment
-import System.Posix.Files
import System.Posix.Env (setEnv)
-import Types
+import AnnexCommon
import Types.Remote
import Types.Key
import qualified Git
-import qualified Annex
import UUID
-import Messages
-import Locations
import Config
import Remote.Helper.Special
import Remote.Helper.Encryptable
@@ -123,7 +113,7 @@ s3Setup u c = handlehost $ M.lookup "host" c
store :: Remote Annex -> Key -> Annex Bool
store r k = s3Action r False $ \(conn, bucket) -> do
- g <- Annex.gitRepo
+ g <- gitRepo
res <- liftIO $ storeHelper (conn, bucket) r k $ gitAnnexLocation g k
s3Bool res
@@ -132,7 +122,7 @@ storeEncrypted r (cipher, enck) k = s3Action r False $ \(conn, bucket) ->
-- To get file size of the encrypted content, have to use a temp file.
-- (An alternative would be chunking to to a constant size.)
withTmp enck $ \tmp -> do
- g <- Annex.gitRepo
+ g <- gitRepo
let f = gitAnnexLocation g k
liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s
res <- liftIO $ storeHelper (conn, bucket) r enck tmp
diff --git a/Remote/Web.hs b/Remote/Web.hs
index 8fb29ec40..732f4d46c 100644
--- a/Remote/Web.hs
+++ b/Remote/Web.hs
@@ -10,21 +10,13 @@ module Remote.Web (
setUrl
) where
-import Control.Monad.State (liftIO)
-import Control.Exception
-import System.FilePath
-
-import Types
+import AnnexCommon
import Types.Remote
import qualified Git
-import qualified Annex
-import Messages
import UUID
import Config
import PresenceLog
import LocationLog
-import Locations
-import Utility
import qualified Utility.Url as Url
type URLString = String
@@ -80,7 +72,7 @@ getUrls key = do
{- Records a change in an url for a key. -}
setUrl :: Key -> URLString -> LogStatus -> Annex ()
setUrl key url status = do
- g <- Annex.gitRepo
+ g <- gitRepo
addLog (urlLog key) =<< logNow status url
-- update location log to indicate that the web has the key, or not