2013-10-28 15:33:14 +00:00
|
|
|
{- git-annex assistant webapp making remotes
|
2012-10-12 05:09:28 +00:00
|
|
|
-
|
|
|
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2013-10-28 15:33:14 +00:00
|
|
|
module Assistant.WebApp.MakeRemote (
|
|
|
|
module Assistant.MakeRemote,
|
|
|
|
module Assistant.WebApp.MakeRemote
|
|
|
|
) where
|
2012-10-12 05:09:28 +00:00
|
|
|
|
2013-03-16 04:12:28 +00:00
|
|
|
import Assistant.Common
|
2012-10-12 05:09:28 +00:00
|
|
|
import Assistant.WebApp.Types
|
|
|
|
import Assistant.Sync
|
|
|
|
import qualified Remote
|
external special remotes mostly implemented (untested)
This has not been tested at all. It compiles!
The only known missing things are support for encryption, and for get/set
of special remote configuration, and of key state. (The latter needs
separate work to add a new per-key log file to store that state.)
Only thing I don't much like is that initremote needs to be passed both
type=external and externaltype=foo. It would be better to have just
type=foo
Most of this is quite straightforward code, that largely wrote itself given
the types. The only tricky parts were:
* Need to lock the remote when using it to eg make a request, because
in theory git-annex could have multiple threads that each try to use
a remote at the same time. I don't think that git-annex ever does
that currently, but better safe than sorry.
* Rather than starting up every external special remote program when
git-annex starts, they are started only on demand, when first used.
This will avoid slowdown, especially when running fast git-annex query
commands. Once started, they keep running until git-annex stops, currently,
which may not be ideal, but it's hard to know a better time to stop them.
* Bit of a chicken and egg problem with caching the cost of the remote,
because setting annex-cost in the git config needs the remote to already
be set up. Managed to finesse that.
This commit was sponsored by Lukas Anzinger.
2013-12-26 22:23:13 +00:00
|
|
|
import qualified Types.Remote as Remote
|
2012-10-12 16:45:16 +00:00
|
|
|
import qualified Config
|
2013-09-29 18:39:10 +00:00
|
|
|
import Config.Cost
|
2013-09-27 04:15:50 +00:00
|
|
|
import Types.StandardGroups
|
2013-11-07 22:02:00 +00:00
|
|
|
import Git.Types (RemoteName)
|
2013-09-27 04:15:50 +00:00
|
|
|
import Logs.PreferredContent
|
|
|
|
import Assistant.MakeRemote
|
2012-10-12 05:09:28 +00:00
|
|
|
|
2013-09-27 04:15:50 +00:00
|
|
|
import Utility.Yesod
|
2012-10-12 05:09:28 +00:00
|
|
|
|
2013-09-27 04:15:50 +00:00
|
|
|
{- Runs an action that creates or enables a cloud remote,
|
2013-09-29 18:39:10 +00:00
|
|
|
- and finishes setting it up, then starts syncing with it,
|
2014-04-20 19:10:29 +00:00
|
|
|
- and finishes by displaying the page to edit it.
|
|
|
|
-
|
|
|
|
- This includes displaying the connectionNeeded nudge if appropariate.
|
|
|
|
-}
|
2013-09-29 18:39:10 +00:00
|
|
|
setupCloudRemote :: StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
|
2014-04-20 19:30:39 +00:00
|
|
|
setupCloudRemote = setupRemote $ redirect . EditNewCloudRepositoryR
|
2014-04-20 19:10:29 +00:00
|
|
|
|
2014-04-20 19:30:39 +00:00
|
|
|
setupRemote :: (UUID -> Handler a) -> StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
|
|
|
|
setupRemote postsetup defaultgroup mcost getname = do
|
2014-04-20 19:10:29 +00:00
|
|
|
r <- liftAnnex $ addRemote getname
|
2013-09-29 18:39:10 +00:00
|
|
|
liftAnnex $ do
|
|
|
|
setStandardGroup (Remote.uuid r) defaultgroup
|
external special remotes mostly implemented (untested)
This has not been tested at all. It compiles!
The only known missing things are support for encryption, and for get/set
of special remote configuration, and of key state. (The latter needs
separate work to add a new per-key log file to store that state.)
Only thing I don't much like is that initremote needs to be passed both
type=external and externaltype=foo. It would be better to have just
type=foo
Most of this is quite straightforward code, that largely wrote itself given
the types. The only tricky parts were:
* Need to lock the remote when using it to eg make a request, because
in theory git-annex could have multiple threads that each try to use
a remote at the same time. I don't think that git-annex ever does
that currently, but better safe than sorry.
* Rather than starting up every external special remote program when
git-annex starts, they are started only on demand, when first used.
This will avoid slowdown, especially when running fast git-annex query
commands. Once started, they keep running until git-annex stops, currently,
which may not be ideal, but it's hard to know a better time to stop them.
* Bit of a chicken and egg problem with caching the cost of the remote,
because setting annex-cost in the git config needs the remote to already
be set up. Managed to finesse that.
This commit was sponsored by Lukas Anzinger.
2013-12-26 22:23:13 +00:00
|
|
|
maybe noop (Config.setRemoteCost (Remote.repo r)) mcost
|
2013-09-27 04:15:50 +00:00
|
|
|
liftAssistant $ syncRemote r
|
2014-04-20 19:30:39 +00:00
|
|
|
postsetup $ Remote.uuid r
|