2012-10-09 18:43:53 +00:00
|
|
|
{- git-annex assistant webapp configurator for editing existing repos
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
2012-10-09 18:43:53 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2020-09-08 16:42:59 +00:00
|
|
|
{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-}
|
2015-05-10 19:54:58 +00:00
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
2012-10-09 18:43:53 +00:00
|
|
|
|
|
|
|
module Assistant.WebApp.Configurators.Edit where
|
|
|
|
|
2012-11-25 04:26:46 +00:00
|
|
|
import Assistant.WebApp.Common
|
2013-09-18 00:02:42 +00:00
|
|
|
import Assistant.WebApp.Gpg
|
2014-04-09 20:27:24 +00:00
|
|
|
import Assistant.WebApp.Configurators
|
2012-10-14 21:18:01 +00:00
|
|
|
import Assistant.DaemonStatus
|
2013-10-28 15:33:14 +00:00
|
|
|
import Assistant.WebApp.MakeRemote (uniqueRemoteName)
|
2013-04-08 20:45:12 +00:00
|
|
|
import Assistant.ScanRemotes
|
2013-10-26 20:54:49 +00:00
|
|
|
import Assistant.Sync
|
2014-04-09 20:27:24 +00:00
|
|
|
import Assistant.Alert
|
2013-04-25 20:42:17 +00:00
|
|
|
import qualified Assistant.WebApp.Configurators.AWS as AWS
|
2015-10-13 17:24:44 +00:00
|
|
|
import qualified Assistant.WebApp.Configurators.IA as IA
|
2013-04-25 20:42:17 +00:00
|
|
|
import qualified Remote.S3 as S3
|
2012-10-09 19:11:48 +00:00
|
|
|
import qualified Remote
|
2013-01-01 17:52:47 +00:00
|
|
|
import qualified Types.Remote as Remote
|
2020-05-27 15:54:39 +00:00
|
|
|
import Remote.List.Util
|
2012-10-09 19:11:48 +00:00
|
|
|
import Logs.UUID
|
2012-10-10 20:04:28 +00:00
|
|
|
import Logs.Group
|
2012-10-10 23:13:49 +00:00
|
|
|
import Logs.PreferredContent
|
2013-04-25 20:42:17 +00:00
|
|
|
import Logs.Remote
|
2012-10-10 20:04:28 +00:00
|
|
|
import Types.StandardGroups
|
2012-10-11 23:36:28 +00:00
|
|
|
import qualified Git
|
2014-03-01 00:37:03 +00:00
|
|
|
import qualified Git.Types as Git
|
2012-10-14 21:18:01 +00:00
|
|
|
import qualified Git.Command
|
2012-10-31 18:39:02 +00:00
|
|
|
import qualified Git.Config
|
2013-03-03 18:55:25 +00:00
|
|
|
import qualified Annex
|
2013-01-14 22:42:15 +00:00
|
|
|
import Git.Remote
|
2020-01-15 17:47:31 +00:00
|
|
|
import Remote.Helper.Encryptable (extractCipher, parseEncryptionConfig)
|
2013-09-18 00:02:42 +00:00
|
|
|
import Types.Crypto
|
|
|
|
import Utility.Gpg
|
2013-11-05 16:38:54 +00:00
|
|
|
import Annex.UUID
|
2020-03-06 16:52:20 +00:00
|
|
|
import Annex.Perms
|
2013-11-07 22:02:00 +00:00
|
|
|
import Assistant.Ssh
|
|
|
|
import Config
|
2017-02-03 17:40:14 +00:00
|
|
|
import Config.GitConfig
|
2017-08-17 16:26:14 +00:00
|
|
|
import Config.DynamicConfig
|
2019-01-09 19:00:43 +00:00
|
|
|
import Types.Group
|
2020-01-10 18:10:20 +00:00
|
|
|
import Types.ProposedAccepted
|
|
|
|
import Annex.SpecialRemote.Config
|
2012-10-09 18:43:53 +00:00
|
|
|
|
|
|
|
import qualified Data.Text as T
|
2012-10-09 19:11:48 +00:00
|
|
|
import qualified Data.Map as M
|
2012-10-10 20:23:41 +00:00
|
|
|
import qualified Data.Set as S
|
|
|
|
|
|
|
|
data RepoGroup = RepoGroupCustom String | RepoGroupStandard StandardGroup
|
|
|
|
deriving (Show, Eq)
|
2012-10-09 19:11:48 +00:00
|
|
|
|
|
|
|
data RepoConfig = RepoConfig
|
2012-10-14 21:18:01 +00:00
|
|
|
{ repoName :: Text
|
|
|
|
, repoDescription :: Maybe Text
|
2012-10-10 20:23:41 +00:00
|
|
|
, repoGroup :: RepoGroup
|
2013-04-26 17:00:14 +00:00
|
|
|
, repoAssociatedDirectory :: Maybe Text
|
2012-10-11 23:22:29 +00:00
|
|
|
, repoSyncable :: Bool
|
2012-10-09 19:11:48 +00:00
|
|
|
}
|
|
|
|
deriving (Show)
|
|
|
|
|
2013-01-01 17:52:47 +00:00
|
|
|
getRepoConfig :: UUID -> Maybe Remote -> Annex RepoConfig
|
2013-04-26 17:00:14 +00:00
|
|
|
getRepoConfig uuid mremote = do
|
2014-05-30 00:12:17 +00:00
|
|
|
-- Ensure we're editing current data by discarding caches.
|
|
|
|
void groupMapLoad
|
2019-01-01 19:39:45 +00:00
|
|
|
void uuidDescMapLoad
|
2014-05-30 00:12:17 +00:00
|
|
|
|
2013-04-26 17:00:14 +00:00
|
|
|
groups <- lookupGroups uuid
|
2020-09-22 17:52:26 +00:00
|
|
|
remoteconfig <- M.lookup uuid <$> remoteConfigMap
|
2013-04-26 17:00:14 +00:00
|
|
|
let (repogroup, associateddirectory) = case getStandardGroup groups of
|
2019-01-09 19:00:43 +00:00
|
|
|
Nothing -> (RepoGroupCustom $ unwords $ map fromGroup $ S.toList groups, Nothing)
|
2013-04-26 17:00:14 +00:00
|
|
|
Just g -> (RepoGroupStandard g, associatedDirectory remoteconfig g)
|
|
|
|
|
2019-01-01 19:39:45 +00:00
|
|
|
description <- fmap (T.pack . fromUUIDDesc) . M.lookup uuid <$> uuidDescMap
|
2013-04-26 17:00:14 +00:00
|
|
|
|
|
|
|
syncable <- case mremote of
|
2017-08-17 16:26:14 +00:00
|
|
|
Just r -> liftIO $ getDynamicConfig $ remoteAnnexSync $ Remote.gitconfig r
|
2017-02-03 17:40:14 +00:00
|
|
|
Nothing -> getGitConfigVal annexAutoCommit
|
2012-10-10 23:13:49 +00:00
|
|
|
|
2013-04-26 17:00:14 +00:00
|
|
|
return $ RepoConfig
|
|
|
|
(T.pack $ maybe "here" Remote.name mremote)
|
|
|
|
description
|
|
|
|
repogroup
|
|
|
|
(T.pack <$> associateddirectory)
|
|
|
|
syncable
|
|
|
|
|
2012-10-14 21:18:01 +00:00
|
|
|
setRepoConfig :: UUID -> Maybe Remote -> RepoConfig -> RepoConfig -> Handler ()
|
|
|
|
setRepoConfig uuid mremote oldc newc = do
|
2013-04-08 20:45:12 +00:00
|
|
|
when descriptionChanged $ liftAnnex $ do
|
2019-01-01 19:39:45 +00:00
|
|
|
maybe noop (describeUUID uuid . toUUIDDesc . T.unpack) (repoDescription newc)
|
|
|
|
void uuidDescMapLoad
|
2013-04-08 20:45:12 +00:00
|
|
|
when nameChanged $ do
|
2013-03-04 20:36:38 +00:00
|
|
|
liftAnnex $ do
|
2018-01-09 19:36:56 +00:00
|
|
|
name <- uniqueRemoteName (legalName newc) 0 <$> Annex.getGitRemotes
|
2012-10-31 18:39:02 +00:00
|
|
|
{- git remote rename expects there to be a
|
|
|
|
- remote.<name>.fetch, and exits nonzero if
|
|
|
|
- there's not. Special remotes don't normally
|
|
|
|
- have that, and don't use it. Temporarily add
|
|
|
|
- it if it's missing. -}
|
2019-12-05 19:10:23 +00:00
|
|
|
let remotefetch = Git.ConfigKey $ encodeBS' $
|
|
|
|
"remote." ++ T.unpack (repoName oldc) ++ ".fetch"
|
2012-10-31 18:39:02 +00:00
|
|
|
needfetch <- isNothing <$> fromRepo (Git.Config.getMaybe remotefetch)
|
|
|
|
when needfetch $
|
2013-03-03 17:39:07 +00:00
|
|
|
inRepo $ Git.Command.run
|
2019-12-05 19:10:23 +00:00
|
|
|
[Param "config", Param (Git.fromConfigKey remotefetch), Param ""]
|
2013-03-03 17:39:07 +00:00
|
|
|
inRepo $ Git.Command.run
|
|
|
|
[ Param "remote"
|
|
|
|
, Param "rename"
|
2012-10-14 21:18:01 +00:00
|
|
|
, Param $ T.unpack $ repoName oldc
|
|
|
|
, Param name
|
|
|
|
]
|
2020-05-27 15:54:39 +00:00
|
|
|
remotesChanged
|
2012-10-30 21:14:26 +00:00
|
|
|
liftAssistant updateSyncRemotes
|
2013-04-26 17:00:14 +00:00
|
|
|
when associatedDirectoryChanged $ case repoAssociatedDirectory newc of
|
|
|
|
Nothing -> noop
|
|
|
|
Just t
|
|
|
|
| T.null t -> noop
|
|
|
|
| otherwise -> liftAnnex $ do
|
|
|
|
let dir = takeBaseName $ T.unpack t
|
2020-09-22 17:52:26 +00:00
|
|
|
m <- remoteConfigMap
|
2013-04-26 17:00:14 +00:00
|
|
|
case M.lookup uuid m of
|
|
|
|
Nothing -> noop
|
|
|
|
Just remoteconfig -> configSet uuid $
|
2020-01-10 18:10:20 +00:00
|
|
|
M.insert (Proposed "preferreddir") (Proposed dir) remoteconfig
|
2013-04-08 20:45:12 +00:00
|
|
|
when groupChanged $ do
|
|
|
|
liftAnnex $ case repoGroup newc of
|
|
|
|
RepoGroupStandard g -> setStandardGroup uuid g
|
2019-01-09 19:00:43 +00:00
|
|
|
RepoGroupCustom s -> groupSet uuid $ S.fromList $ map toGroup $ words s
|
2013-04-08 20:45:12 +00:00
|
|
|
{- Enabling syncing will cause a scan,
|
|
|
|
- so avoid queueing a duplicate scan. -}
|
|
|
|
when (repoSyncable newc && not syncableChanged) $ liftAssistant $
|
|
|
|
case mremote of
|
2013-10-02 05:06:59 +00:00
|
|
|
Just remote -> addScanRemotes True [remote]
|
|
|
|
Nothing -> addScanRemotes True
|
|
|
|
=<< syncDataRemotes <$> getDaemonStatus
|
2013-04-08 20:45:12 +00:00
|
|
|
when syncableChanged $
|
2013-10-26 20:54:49 +00:00
|
|
|
liftAssistant $ changeSyncable mremote (repoSyncable newc)
|
2013-04-08 20:45:12 +00:00
|
|
|
where
|
2014-10-09 18:53:13 +00:00
|
|
|
syncableChanged = repoSyncable oldc /= repoSyncable newc
|
2013-04-26 17:00:14 +00:00
|
|
|
associatedDirectoryChanged = repoAssociatedDirectory oldc /= repoAssociatedDirectory newc
|
2013-04-08 20:45:12 +00:00
|
|
|
groupChanged = repoGroup oldc /= repoGroup newc
|
|
|
|
nameChanged = isJust mremote && legalName oldc /= legalName newc
|
|
|
|
descriptionChanged = repoDescription oldc /= repoDescription newc
|
|
|
|
|
|
|
|
legalName = makeLegalName . T.unpack . repoName
|
2012-10-11 21:14:42 +00:00
|
|
|
|
2018-06-04 18:31:55 +00:00
|
|
|
editRepositoryAForm :: Maybe Git.Repo -> Maybe Remote -> RepoConfig -> MkAForm RepoConfig
|
|
|
|
editRepositoryAForm mrepo mremote d = RepoConfig
|
2013-06-18 21:08:37 +00:00
|
|
|
<$> areq (if ishere then readonlyTextField else textField)
|
2015-01-28 20:11:28 +00:00
|
|
|
(bfs "Name") (Just $ repoName d)
|
|
|
|
<*> aopt textField (bfs "Description") (Just $ repoDescription d)
|
|
|
|
<*> areq (selectFieldList groups `withNote` help) (bfs "Repository group") (Just $ repoGroup d)
|
2013-04-26 17:00:14 +00:00
|
|
|
<*> associateddirectory
|
2015-01-28 20:11:28 +00:00
|
|
|
<*> areq checkBoxField "Syncing enabled" (Just $ repoSyncable d)
|
2012-10-31 06:34:03 +00:00
|
|
|
where
|
2014-03-01 00:37:03 +00:00
|
|
|
ishere = isNothing mremote
|
2018-06-04 18:31:55 +00:00
|
|
|
isspecial = maybe False ((== Git.Unknown) . Git.location) mrepo
|
2012-12-03 02:33:30 +00:00
|
|
|
groups = customgroups ++ standardgroups
|
2012-10-31 06:34:03 +00:00
|
|
|
standardgroups :: [(Text, RepoGroup)]
|
2014-03-01 00:37:03 +00:00
|
|
|
standardgroups = map (\g -> (T.pack $ descStandardGroup g , RepoGroupStandard g)) $
|
|
|
|
filter sanegroup [minBound..maxBound]
|
|
|
|
sanegroup
|
|
|
|
| isspecial = const True
|
|
|
|
| otherwise = not . specialRemoteOnly
|
2012-10-31 06:34:03 +00:00
|
|
|
customgroups :: [(Text, RepoGroup)]
|
2015-01-28 20:11:28 +00:00
|
|
|
customgroups = case repoGroup d of
|
2012-10-31 06:34:03 +00:00
|
|
|
RepoGroupCustom s -> [(T.pack s, RepoGroupCustom s)]
|
|
|
|
_ -> []
|
2012-12-03 02:33:30 +00:00
|
|
|
help = [whamlet|<a href="@{RepoGroupR}">What's this?</a>|]
|
2012-10-09 19:11:48 +00:00
|
|
|
|
2015-01-28 20:11:28 +00:00
|
|
|
associateddirectory = case repoAssociatedDirectory d of
|
2013-04-26 19:06:18 +00:00
|
|
|
Nothing -> aopt hiddenField "" Nothing
|
2015-01-28 20:11:28 +00:00
|
|
|
Just dir -> aopt textField (bfs "Associated directory") (Just $ Just dir)
|
2013-04-26 17:00:14 +00:00
|
|
|
|
2013-11-07 22:02:00 +00:00
|
|
|
getEditRepositoryR :: RepoId -> Handler Html
|
2013-03-16 22:48:23 +00:00
|
|
|
getEditRepositoryR = postEditRepositoryR
|
|
|
|
|
2013-11-07 22:02:00 +00:00
|
|
|
postEditRepositoryR :: RepoId -> Handler Html
|
2013-03-16 22:48:23 +00:00
|
|
|
postEditRepositoryR = editForm False
|
2012-10-11 21:35:08 +00:00
|
|
|
|
2013-06-27 05:15:28 +00:00
|
|
|
getEditNewRepositoryR :: UUID -> Handler Html
|
2013-03-16 22:48:23 +00:00
|
|
|
getEditNewRepositoryR = postEditNewRepositoryR
|
|
|
|
|
2013-06-27 05:15:28 +00:00
|
|
|
postEditNewRepositoryR :: UUID -> Handler Html
|
2013-11-07 22:02:00 +00:00
|
|
|
postEditNewRepositoryR = editForm True . RepoUUID
|
2012-10-11 21:35:08 +00:00
|
|
|
|
2013-06-27 05:15:28 +00:00
|
|
|
getEditNewCloudRepositoryR :: UUID -> Handler Html
|
2013-03-16 22:48:23 +00:00
|
|
|
getEditNewCloudRepositoryR = postEditNewCloudRepositoryR
|
|
|
|
|
2013-06-27 05:15:28 +00:00
|
|
|
postEditNewCloudRepositoryR :: UUID -> Handler Html
|
2014-04-09 20:27:24 +00:00
|
|
|
postEditNewCloudRepositoryR uuid = connectionNeeded >> editForm True (RepoUUID uuid)
|
2012-10-27 16:25:29 +00:00
|
|
|
|
2013-11-07 22:02:00 +00:00
|
|
|
editForm :: Bool -> RepoId -> Handler Html
|
2014-08-12 20:35:13 +00:00
|
|
|
editForm new (RepoUUID uuid)
|
2014-12-17 17:59:23 +00:00
|
|
|
| uuid == webUUID || uuid == bitTorrentUUID = page "The web" (Just Configuration) $ do
|
2014-08-12 20:35:13 +00:00
|
|
|
$(widgetFile "configurators/edit/webrepository")
|
|
|
|
| otherwise = page "Edit repository" (Just Configuration) $ do
|
|
|
|
mremote <- liftAnnex $ Remote.remoteFromUUID uuid
|
|
|
|
when (mremote == Nothing) $
|
|
|
|
whenM ((/=) uuid <$> liftAnnex getUUID) $
|
|
|
|
error "unknown remote"
|
|
|
|
curr <- liftAnnex $ getRepoConfig uuid mremote
|
|
|
|
liftAnnex $ checkAssociatedDirectory curr mremote
|
2018-06-04 18:31:55 +00:00
|
|
|
mrepo <- liftAnnex $
|
|
|
|
maybe (pure Nothing) (Just <$$> Remote.getRepo) mremote
|
2014-08-12 20:35:13 +00:00
|
|
|
((result, form), enctype) <- liftH $
|
2018-06-04 18:31:55 +00:00
|
|
|
runFormPostNoToken $ renderBootstrap3 bootstrapFormLayout $
|
|
|
|
editRepositoryAForm mrepo mremote curr
|
2014-08-12 20:35:13 +00:00
|
|
|
case result of
|
|
|
|
FormSuccess input -> liftH $ do
|
|
|
|
setRepoConfig uuid mremote curr input
|
|
|
|
liftAnnex $ checkAssociatedDirectory input mremote
|
|
|
|
redirect DashboardR
|
|
|
|
_ -> do
|
|
|
|
let istransfer = repoGroup curr == RepoGroupStandard TransferGroup
|
2020-01-15 17:47:31 +00:00
|
|
|
config <- liftAnnex $ fromMaybe mempty
|
|
|
|
. M.lookup uuid
|
2020-09-22 17:52:26 +00:00
|
|
|
<$> remoteConfigMap
|
2014-08-12 20:35:13 +00:00
|
|
|
let repoInfo = getRepoInfo mremote config
|
2020-01-15 17:47:31 +00:00
|
|
|
let repoEncryption = getRepoEncryption mremote (Just config)
|
2014-08-12 20:35:13 +00:00
|
|
|
$(widgetFile "configurators/edit/repository")
|
2013-12-19 02:39:15 +00:00
|
|
|
editForm _new r@(RepoName _) = page "Edit repository" (Just Configuration) $ do
|
2013-11-07 22:02:00 +00:00
|
|
|
mr <- liftAnnex (repoIdRemote r)
|
2020-01-15 17:47:31 +00:00
|
|
|
let repoInfo = case mr of
|
|
|
|
Just rmt -> do
|
|
|
|
config <- liftAnnex $ fromMaybe mempty
|
|
|
|
. M.lookup (Remote.uuid rmt)
|
2020-09-22 17:52:26 +00:00
|
|
|
<$> remoteConfigMap
|
2020-01-15 17:47:31 +00:00
|
|
|
getRepoInfo mr config
|
|
|
|
Nothing -> getRepoInfo Nothing mempty
|
2013-11-07 22:02:00 +00:00
|
|
|
g <- liftAnnex gitRepo
|
2018-06-04 18:31:55 +00:00
|
|
|
mrepo <- liftAnnex $ maybe (pure Nothing) (Just <$$> Remote.getRepo) mr
|
|
|
|
let sshrepo = maybe False (remoteLocationIsSshUrl . flip parseRemoteLocation g . Git.repoLocation) mrepo
|
2013-11-07 22:02:00 +00:00
|
|
|
$(widgetFile "configurators/edit/nonannexremote")
|
2013-04-26 17:00:14 +00:00
|
|
|
|
|
|
|
{- Makes any directory associated with the repository. -}
|
|
|
|
checkAssociatedDirectory :: RepoConfig -> Maybe Remote -> Annex ()
|
|
|
|
checkAssociatedDirectory _ Nothing = noop
|
|
|
|
checkAssociatedDirectory cfg (Just r) = do
|
2020-09-22 17:52:26 +00:00
|
|
|
repoconfig <- M.lookup (Remote.uuid r) <$> remoteConfigMap
|
2013-04-26 17:00:14 +00:00
|
|
|
case repoGroup cfg of
|
|
|
|
RepoGroupStandard gr -> case associatedDirectory repoconfig gr of
|
2020-03-06 16:52:20 +00:00
|
|
|
Just d -> do
|
|
|
|
top <- fromRawFilePath <$> fromRepo Git.repoPath
|
2020-11-04 18:20:37 +00:00
|
|
|
createWorkTreeDirectory (toRawFilePath (top </> d))
|
2013-04-26 03:44:55 +00:00
|
|
|
Nothing -> noop
|
|
|
|
_ -> noop
|
2013-04-25 20:42:17 +00:00
|
|
|
|
2020-01-15 17:47:31 +00:00
|
|
|
getRepoInfo :: Maybe Remote.Remote -> Remote.RemoteConfig -> Widget
|
|
|
|
getRepoInfo (Just r) c = case fromProposedAccepted <$> M.lookup typeField c of
|
|
|
|
Just "S3" -> do
|
fix encryption of content to gcrypt and git-lfs
Fix serious regression in gcrypt and encrypted git-lfs remotes.
Since version 7.20200202.7, git-annex incorrectly stored content
on those remotes without encrypting it.
Problem was, Remote.Git enumerates all git remotes, including git-lfs
and gcrypt. It then dispatches to those. So, Remote.List used the
RemoteConfigParser from Remote.Git, instead of from git-lfs or gcrypt,
and that parser does not know about encryption fields, so did not
include them in the ParsedRemoteConfig. (Also didn't include other
fields specific to those remotes, perhaps chunking etc also didn't
get through.)
To fix, had to move RemoteConfig parsing down into the generate methods
of each remote, rather than doing it in Remote.List.
And a consequence of that was that ParsedRemoteConfig had to change to
include the RemoteConfig that got parsed, so that testremote can
generate a new remote based on an existing remote.
(I would have rather fixed this just inside Remote.Git, but that was not
practical, at least not w/o re-doing work that Remote.List already did.
Big ugly mostly mechanical patch seemed preferable to making git-annex
slower.)
2020-02-26 21:20:56 +00:00
|
|
|
pc <- liftAnnex $ parsedRemoteConfig S3.remote c
|
2020-01-15 17:47:31 +00:00
|
|
|
if S3.configIA pc
|
|
|
|
then IA.getRepoInfo c
|
|
|
|
else AWS.getRepoInfo c
|
2013-04-25 20:42:17 +00:00
|
|
|
Just t
|
|
|
|
| t /= "git" -> [whamlet|#{t} remote|]
|
2018-06-04 18:31:55 +00:00
|
|
|
_ -> getGitRepoInfo =<< liftAnnex (Remote.getRepo r)
|
2013-04-25 20:42:17 +00:00
|
|
|
getRepoInfo _ _ = [whamlet|git repository|]
|
|
|
|
|
|
|
|
getGitRepoInfo :: Git.Repo -> Widget
|
|
|
|
getGitRepoInfo r = do
|
|
|
|
let loc = Git.repoLocation r
|
|
|
|
[whamlet|git repository located at <tt>#{loc}</tt>|]
|
2013-09-18 00:02:42 +00:00
|
|
|
|
|
|
|
getRepoEncryption :: Maybe Remote.Remote -> Maybe Remote.RemoteConfig -> Widget
|
2020-01-15 17:47:31 +00:00
|
|
|
getRepoEncryption (Just _) (Just c) = case extractCipher pc of
|
2014-10-09 18:53:13 +00:00
|
|
|
Nothing ->
|
2013-09-18 00:02:42 +00:00
|
|
|
[whamlet|not encrypted|]
|
|
|
|
(Just (SharedCipher _)) ->
|
|
|
|
[whamlet|encrypted: encryption key stored in git repository|]
|
2016-05-11 16:37:13 +00:00
|
|
|
(Just (EncryptedCipher _ _ ks)) -> desckeys ks
|
|
|
|
(Just (SharedPubKeyCipher _ ks)) -> desckeys ks
|
|
|
|
where
|
fix encryption of content to gcrypt and git-lfs
Fix serious regression in gcrypt and encrypted git-lfs remotes.
Since version 7.20200202.7, git-annex incorrectly stored content
on those remotes without encrypting it.
Problem was, Remote.Git enumerates all git remotes, including git-lfs
and gcrypt. It then dispatches to those. So, Remote.List used the
RemoteConfigParser from Remote.Git, instead of from git-lfs or gcrypt,
and that parser does not know about encryption fields, so did not
include them in the ParsedRemoteConfig. (Also didn't include other
fields specific to those remotes, perhaps chunking etc also didn't
get through.)
To fix, had to move RemoteConfig parsing down into the generate methods
of each remote, rather than doing it in Remote.List.
And a consequence of that was that ParsedRemoteConfig had to change to
include the RemoteConfig that got parsed, so that testremote can
generate a new remote based on an existing remote.
(I would have rather fixed this just inside Remote.Git, but that was not
practical, at least not w/o re-doing work that Remote.List already did.
Big ugly mostly mechanical patch seemed preferable to making git-annex
slower.)
2020-02-26 21:20:56 +00:00
|
|
|
pc = either (const (Remote.ParsedRemoteConfig mempty mempty)) id $
|
|
|
|
parseEncryptionConfig c
|
2016-05-11 16:37:13 +00:00
|
|
|
desckeys (KeyIds { keyIds = ks }) = do
|
2015-09-09 22:06:49 +00:00
|
|
|
cmd <- liftAnnex $ gpgCmd <$> Annex.getGitConfig
|
|
|
|
knownkeys <- liftIO (secretKeys cmd)
|
2013-09-18 00:02:42 +00:00
|
|
|
[whamlet|
|
|
|
|
encrypted using gpg key:
|
|
|
|
<ul style="list-style: none">
|
|
|
|
$forall k <- ks
|
|
|
|
<li>
|
|
|
|
^{gpgKeyDisplay k (M.lookup k knownkeys)}
|
|
|
|
|]
|
2013-09-20 16:19:55 +00:00
|
|
|
getRepoEncryption _ _ = return () -- local repo
|
2013-11-07 22:02:00 +00:00
|
|
|
|
|
|
|
getUpgradeRepositoryR :: RepoId -> Handler ()
|
|
|
|
getUpgradeRepositoryR (RepoUUID _) = redirect DashboardR
|
|
|
|
getUpgradeRepositoryR r = go =<< liftAnnex (repoIdRemote r)
|
|
|
|
where
|
2014-10-09 18:53:13 +00:00
|
|
|
go Nothing = redirect DashboardR
|
2013-11-07 22:02:00 +00:00
|
|
|
go (Just rmt) = do
|
2013-12-21 00:58:36 +00:00
|
|
|
liftIO fixSshKeyPairIdentitiesOnly
|
2018-06-04 18:31:55 +00:00
|
|
|
liftAnnex $ do
|
|
|
|
repo <- Remote.getRepo rmt
|
|
|
|
setConfig
|
2020-02-19 17:45:11 +00:00
|
|
|
(remoteAnnexConfig repo "ignore")
|
2018-06-04 18:31:55 +00:00
|
|
|
(Git.Config.boolConfig False)
|
2020-05-27 15:54:39 +00:00
|
|
|
liftAnnex remotesChanged
|
2014-01-26 17:57:05 +00:00
|
|
|
liftAssistant updateSyncRemotes
|
|
|
|
liftAssistant $ syncRemote rmt
|
2013-11-07 22:02:00 +00:00
|
|
|
redirect DashboardR
|
2014-04-09 20:27:24 +00:00
|
|
|
|
|
|
|
{- If there is no currently connected remote, display an alert suggesting
|
|
|
|
- to set up one. -}
|
|
|
|
connectionNeeded :: Handler ()
|
|
|
|
connectionNeeded = whenM noconnection $ do
|
|
|
|
urlrender <- getUrlRender
|
|
|
|
void $ liftAssistant $ do
|
|
|
|
close <- asIO1 removeAlert
|
|
|
|
addAlert $ connectionNeededAlert $ AlertButton
|
2014-06-02 22:04:21 +00:00
|
|
|
{ buttonLabel = "Connect"
|
2014-04-09 20:27:24 +00:00
|
|
|
, buttonUrl = urlrender ConnectionNeededR
|
|
|
|
, buttonAction = Just close
|
|
|
|
, buttonPrimary = True
|
|
|
|
}
|
|
|
|
where
|
|
|
|
noconnection = S.null . currentlyConnectedRemotes <$> liftAssistant getDaemonStatus
|
|
|
|
|
|
|
|
getConnectionNeededR :: Handler Html
|
|
|
|
getConnectionNeededR = page "Connection needed" (Just Configuration) $ do
|
|
|
|
$(widgetFile "configurators/needconnection")
|