webapp: Fix bug when adding a remote and git-remote-gcrypt is not installed.

This commit is contained in:
Joey Hess 2013-10-22 13:32:10 -04:00
parent c1166aaad7
commit 00932eda06
5 changed files with 31 additions and 19 deletions

View file

@ -294,11 +294,11 @@ getFinishAddDriveR drive = go
r <- liftAnnex $ addRemote $ r <- liftAnnex $ addRemote $
makeGCryptRemote remotename dir keyid makeGCryptRemote remotename dir keyid
return (Types.Remote.uuid r, r) return (Types.Remote.uuid r, r)
go NoRepoKey = checkGCryptRepoEncryption dir makeunencrypted $ do go NoRepoKey = checkGCryptRepoEncryption dir makeunencrypted makeunencrypted $ do
mu <- liftAnnex $ probeGCryptRemoteUUID dir mu <- liftAnnex $ probeGCryptRemoteUUID dir
case mu of case mu of
Just u -> enableexistinggcryptremote u Just u -> enableexistinggcryptremote u
Nothing -> error "The drive contains a gcrypt repository that is not a git-annex special remote. This is not supported." Nothing -> error "The drive contains a gcrypt repository that is not a git-annex special remote. This is not supported."
enableexistinggcryptremote u = do enableexistinggcryptremote u = do
remotename' <- liftAnnex $ getGCryptRemoteName u dir remotename' <- liftAnnex $ getGCryptRemoteName u dir
makewith $ const $ do makewith $ const $ do

View file

@ -342,15 +342,12 @@ getMakeSshGCryptR sshdata (RepoKey keyid) = whenGcryptInstalled $
{- Detect if the user entered a location with an existing, known {- Detect if the user entered a location with an existing, known
- gcrypt repository, and enable it. Otherwise, runs the action. -} - gcrypt repository, and enable it. Otherwise, runs the action. -}
checkExistingGCrypt :: SshData -> Widget -> Widget checkExistingGCrypt :: SshData -> Widget -> Widget
checkExistingGCrypt sshdata nope = ifM (liftIO isGcryptInstalled) checkExistingGCrypt sshdata nope = checkGCryptRepoEncryption repourl nope nope $ do
( checkGCryptRepoEncryption repourl nope $ do mu <- liftAnnex $ probeGCryptRemoteUUID repourl
mu <- liftAnnex $ probeGCryptRemoteUUID repourl case mu of
case mu of Just u -> void $ liftH $
Just u -> void $ liftH $ combineExistingGCrypt sshdata u
combineExistingGCrypt sshdata u Nothing -> error "The location contains a gcrypt repository that is not a git-annex special remote. This is not supported."
Nothing -> error "The location contains a gcrypt repository that is not a git-annex special remote. This is not supported."
, nope
)
where where
repourl = genSshUrl sshdata repourl = genSshUrl sshdata
@ -465,11 +462,12 @@ enableRsyncNet sshinput reponame =
enableRsyncNetGCrypt :: SshInput -> RemoteName -> Handler Html enableRsyncNetGCrypt :: SshInput -> RemoteName -> Handler Html
enableRsyncNetGCrypt sshinput reponame = enableRsyncNetGCrypt sshinput reponame =
prepRsyncNet sshinput reponame $ \sshdata -> prepRsyncNet sshinput reponame $ \sshdata -> whenGcryptInstalled $
checkGCryptRepoEncryption (genSshUrl sshdata) notencrypted $ checkGCryptRepoEncryption (genSshUrl sshdata) notencrypted notinstalled $
enableGCrypt sshdata reponame enableGCrypt sshdata reponame
where where
notencrypted = error "Unexpectedly found a non-encrypted git repository, instead of the expected encrypted git repository." notencrypted = error "Unexpectedly found a non-encrypted git repository, instead of the expected encrypted git repository."
notinstalled = error "internal"
{- Prepares rsync.net ssh key, and if successful, runs an action with {- Prepares rsync.net ssh key, and if successful, runs an action with
- its SshData. -} - its SshData. -}

View file

@ -79,9 +79,18 @@ getGCryptRemoteName u repoloc = do
where where
missing = error $ "Cannot find configuration for the gcrypt remote at " ++ repoloc missing = error $ "Cannot find configuration for the gcrypt remote at " ++ repoloc
checkGCryptRepoEncryption :: (Monad m, LiftAnnex m) => String -> m a -> m a -> m a {- Checks to see if a repo is encrypted with gcrypt, and runs one action if
checkGCryptRepoEncryption location notencrypted encrypted = - it's not an another if it is.
dispatch =<< liftAnnex (inRepo $ Git.GCrypt.probeRepo location) -
- Since the probing requires gcrypt to be installed, a third action must
- be provided to run if it's not installed.
-}
checkGCryptRepoEncryption :: (Monad m, MonadIO m, LiftAnnex m) => String -> m a -> m a -> m a -> m a
checkGCryptRepoEncryption location notencrypted notinstalled encrypted =
ifM (liftIO isGcryptInstalled)
( dispatch =<< liftAnnex (inRepo $ Git.GCrypt.probeRepo location)
, notinstalled
)
where where
dispatch Git.GCrypt.Decryptable = encrypted dispatch Git.GCrypt.Decryptable = encrypted
dispatch Git.GCrypt.NotEncrypted = notencrypted dispatch Git.GCrypt.NotEncrypted = notencrypted

2
debian/changelog vendored
View file

@ -1,5 +1,7 @@
git-annex (4.20131003) UNRELEASED; urgency=low git-annex (4.20131003) UNRELEASED; urgency=low
* webapp: Fix bug when adding a remote and git-remote-gcrypt
is not installed.
* The assitant can now run scheduled incremental fsck jobs on the local * The assitant can now run scheduled incremental fsck jobs on the local
repository and remotes. These can be configured using vicfg or with the repository and remotes. These can be configured using vicfg or with the
webapp. webapp.

View file

@ -64,3 +64,6 @@ h the git-annex assistant, paste in .git/annex/daemon.log
"""]] """]]
I'm not at my computer, will check upstream Git later. Sorry if this has been reported before. I'm not at my computer, will check upstream Git later. Sorry if this has been reported before.
> This only occurred when git-remote-gcrypt was not installed.
> I've fixed the bug. [[done]] --[[Joey]]