diff options
author | Joey Hess <joey@kitenet.net> | 2013-09-07 18:38:00 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-09-07 18:38:00 -0400 |
commit | eb259a74840fc7e4769a3ba3384b635b3b4ef5be (patch) | |
tree | 3a4df1961af9e3e4b6c58efef1a99885e0a375ca /Command | |
parent | 98ae5c42b47c7acf47d8436fcd061b1fbc0d9796 (diff) |
partially complete gcrypt remote (local send done; rest not)
This is a git-remote-gcrypt encrypted special remote. Only sending files
in to the remote works, and only for local repositories.
Most of the work so far has involved making initremote work. A particular
problem is that remote setup in this case needs to generate its own uuid,
derivied from the gcrypt-id. That required some larger changes in the code
to support.
For ssh remotes, this will probably just reuse Remote.Rsync's code, so
should be easy enough. And for downloading from a web remote, I will need
to factor out the part of Remote.Git that does that.
One particular thing that will need work is supporting hot-swapping a local
gcrypt remote. I think it needs to store the gcrypt-id in the git config of the
local remote, so that it can check it every time, and compare with the
cached annex-uuid for the remote. If there is a mismatch, it can change
both the cached annex-uuid and the gcrypt-id. That should work, and I laid
some groundwork for it by already reading the remote's config when it's
local. (Also needed for other reasons.)
This commit was sponsored by Daniel Callahan.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/EnableRemote.hs | 4 | ||||
-rw-r--r-- | Command/InitRemote.hs | 17 |
2 files changed, 9 insertions, 12 deletions
diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs index ea606c284..977c80487 100644 --- a/Command/EnableRemote.hs +++ b/Command/EnableRemote.hs @@ -47,8 +47,8 @@ unknownNameError prefix = do perform :: RemoteType -> UUID -> R.RemoteConfig -> CommandPerform perform t u c = do - c' <- R.setup t u c - next $ cleanup u c' + (c', u') <- R.setup t (Just u) c + next $ cleanup u' c' cleanup :: UUID -> R.RemoteConfig -> CommandCleanup cleanup u c = do diff --git a/Command/InitRemote.hs b/Command/InitRemote.hs index 684a2cc91..5a240f800 100644 --- a/Command/InitRemote.hs +++ b/Command/InitRemote.hs @@ -14,7 +14,6 @@ import Command import qualified Remote import qualified Logs.Remote import qualified Types.Remote as R -import Annex.UUID import Logs.UUID import Logs.Trust @@ -34,18 +33,18 @@ start (name:ws) = ifM (isJust <$> findExisting name) ( error $ "There is already a special remote named \"" ++ name ++ "\". (Use enableremote to enable an existing special remote.)" , do - (u, c) <- generateNew name + let c = newConfig name t <- findType config showStart "initremote" name - next $ perform t u name $ M.union config c + next $ perform t name $ M.union config c ) where config = Logs.Remote.keyValToConfig ws -perform :: RemoteType -> UUID -> String -> R.RemoteConfig -> CommandPerform -perform t u name c = do - c' <- R.setup t u c +perform :: RemoteType -> String -> R.RemoteConfig -> CommandPerform +perform t name c = do + (c', u) <- R.setup t Nothing c next $ cleanup u name c' cleanup :: UUID -> String -> R.RemoteConfig -> CommandCleanup @@ -63,10 +62,8 @@ findExisting name = do <$> Logs.Remote.readRemoteLog return $ headMaybe matches -generateNew :: String -> Annex (UUID, R.RemoteConfig) -generateNew name = do - uuid <- liftIO genUUID - return (uuid, M.singleton nameKey name) +newConfig :: String -> R.RemoteConfig +newConfig name = M.singleton nameKey name findByName :: String -> M.Map UUID R.RemoteConfig -> [(UUID, R.RemoteConfig)] findByName n = filter (matching . snd) . M.toList |