if keys database cannot be opened due to permissions, ignore

This lets readonly repos be used. If a repo is readonly, we can ignore the
keys database, because nothing that we can do will change the state of the
repo anyway.
This commit is contained in:
Joey Hess 2016-02-12 14:15:28 -04:00
parent 0983f136b8
commit 9df13e73ae
Failed to extract signature
5 changed files with 33 additions and 7 deletions

View file

@ -21,7 +21,8 @@ module Utility.Exception (
tryNonAsync,
tryWhenExists,
catchIOErrorType,
IOErrorType(..)
IOErrorType(..),
catchPermissionDenied,
) where
import Control.Monad.Catch as X hiding (Handler)
@ -97,3 +98,6 @@ catchIOErrorType errtype onmatchingerr a = catchIO a onlymatching
onlymatching e
| ioeGetErrorType e == errtype = onmatchingerr e
| otherwise = throwM e
catchPermissionDenied :: MonadCatch m => (IOException -> m a) -> m a -> m a
catchPermissionDenied = catchIOErrorType PermissionDenied