From ad1955b4063befa51a36932794f49193a307a23f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Feb 2016 14:15:28 -0400 Subject: 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. --- Utility/Exception.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Utility/Exception.hs') diff --git a/Utility/Exception.hs b/Utility/Exception.hs index 8b110ae6d..e691f13b6 100644 --- a/Utility/Exception.hs +++ b/Utility/Exception.hs @@ -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 -- cgit v1.2.3