check if git-remote-gcrypt is installed
This commit is contained in:
parent
b37aad6c06
commit
490aa67d10
2 changed files with 30 additions and 18 deletions
|
@ -274,33 +274,35 @@ cloneModal = $(widgetFile "configurators/adddrive/clonemodal")
|
|||
|
||||
getFinishAddDriveR :: RemovableDriveKey -> Handler Html
|
||||
getFinishAddDriveR (RemovableDriveKey drive mkeyid) =
|
||||
make >>= redirect . EditNewRepositoryR
|
||||
maybe setupclear setupencrypted mkeyid
|
||||
where
|
||||
make = do
|
||||
setupclear = makewith $ \isnew -> (,)
|
||||
<$> liftIO (initRepo isnew False dir $ Just remotename)
|
||||
<*> combineRepos dir remotename
|
||||
setupencrypted keyid = ifM (liftIO $ inPath "git-remote-gcrypt")
|
||||
( makewith $ \_ -> do
|
||||
r <- liftAnnex $ addRemote $
|
||||
initSpecialRemote remotename GCrypt.remote $ M.fromList
|
||||
[ ("type", "gcrypt")
|
||||
, ("gitrepo", dir)
|
||||
, configureEncryption HybridEncryption
|
||||
, ("keyid", keyid)
|
||||
]
|
||||
return (Types.Remote.uuid r, r)
|
||||
, page "Encrypt repository" (Just Configuration) $
|
||||
$(widgetFile "configurators/needgcrypt")
|
||||
)
|
||||
makewith a = do
|
||||
liftIO $ createDirectoryIfMissing True dir
|
||||
isnew <- liftIO $ makeRepo dir True
|
||||
{- Removable drives are not reliable media, so enable fsync. -}
|
||||
liftIO $ inDir dir $
|
||||
setConfig (ConfigKey "core.fsyncobjectfiles")
|
||||
(Git.Config.boolConfig True)
|
||||
maybe (setupclear isnew) setupencrypted mkeyid
|
||||
setupclear isnew = do
|
||||
u <- liftIO $ initRepo isnew False dir $ Just remotename
|
||||
r <- combineRepos dir remotename
|
||||
finishsetup u r
|
||||
setupencrypted keyid = do
|
||||
r <- liftAnnex $ addRemote $
|
||||
initSpecialRemote remotename GCrypt.remote $ M.fromList
|
||||
[ ("type", "gcrypt")
|
||||
, ("gitrepo", dir)
|
||||
, configureEncryption HybridEncryption
|
||||
, ("keyid", keyid)
|
||||
]
|
||||
finishsetup (Types.Remote.uuid r) r
|
||||
finishsetup u r = do
|
||||
(u, r) <- a isnew
|
||||
liftAnnex $ setStandardGroup u TransferGroup
|
||||
liftAssistant $ syncRemote r
|
||||
return u
|
||||
redirect $ EditNewRepositoryR u
|
||||
mountpoint = T.unpack (mountPoint drive)
|
||||
dir = removableDriveRepository drive
|
||||
remotename = takeFileName mountpoint
|
||||
|
|
10
templates/configurators/needgcrypt.hamlet
Normal file
10
templates/configurators/needgcrypt.hamlet
Normal file
|
@ -0,0 +1,10 @@
|
|||
<div .span9 .hero-unit>
|
||||
<h2>
|
||||
Need git-remote-gcrypt
|
||||
<p>
|
||||
To encrypt git repositories, you need to install #
|
||||
<a href="https://github.com/joeyh/git-remote-gcrypt">
|
||||
git-remote-gcrypt
|
||||
<p>
|
||||
<a .btn .btn-primary .btn-large href="">
|
||||
Retry
|
Loading…
Reference in a new issue