diff options
author | Joey Hess <joeyh@joeyh.name> | 2020-02-14 13:12:26 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2020-02-14 13:12:34 -0400 |
commit | d083843a1f668cf1081b3fd90e390c36698ac604 (patch) | |
tree | 61ee7d13191f8a8ca11f86c823b2427179510463 /Storage | |
parent | 35e03f947c8c0a15f18229b8d5c6f822b88df94c (diff) | |
download | keysafe-d083843a1f668cf1081b3fd90e390c36698ac604.tar.gz |
updated many dependencies, ghc 8.x
Updated many dependencies, notably secret-sharing which dropped the dep on
polynomial, and so allows building with ghc 8.x.
Did not try to support building with older ghc because the semigroup-monid
transition would make it nontrivial.
Stackage lts-14.25 is a compromise, since the stack shipped in debian (even
unstable) is not able to handle newer ones.
This commit was sponsored by Eric Drechsel on Patreon.
Diffstat (limited to 'Storage')
-rw-r--r-- | Storage/Local.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Storage/Local.hs b/Storage/Local.hs index c1dcea4..cebd613 100644 --- a/Storage/Local.hs +++ b/Storage/Local.hs @@ -20,7 +20,6 @@ import Utility.UserInfo import Utility.Exception import qualified Data.ByteString as B import qualified Data.ByteString.UTF8 as U8 -import Data.Monoid import Data.List import Data.Maybe import System.IO @@ -52,7 +51,7 @@ localStorage storagelevel getsharedir n = Storage section = Section n localStorageOverride :: FilePath -> IO (Maybe Storage) -localStorageOverride d = onError' accesserror $ do +localStorageOverride d = onStorageError' accesserror $ do -- Check that the directory can be written to. createDirectoryIfMissing True d -- Use a filename as long as used for keysafe share files. @@ -67,7 +66,7 @@ localStorageOverride d = onError' accesserror $ do return Nothing store :: Section -> GetShareDir -> StorableObjectIdent -> Share -> IO StoreResult -store section getsharedir i s = onError (StoreFailure . show) $ do +store section getsharedir i s = onStorageError (StoreFailure . show) $ do dir <- getsharedir section createDirectoryIfMissing True dir let dest = dir </> shareFile i @@ -85,7 +84,7 @@ store section getsharedir i s = onError (StoreFailure . show) $ do return StoreSuccess retrieve :: Section -> GetShareDir -> ShareNum -> StorableObjectIdent -> IO RetrieveResult -retrieve section getsharedir n i = onError (RetrieveFailure . show) $ do +retrieve section getsharedir n i = onStorageError (RetrieveFailure . show) $ do dir <- getsharedir section fd <- openFd (dir </> shareFile i) ReadOnly Nothing defaultFileFlags h <- fdToHandle fd @@ -103,14 +102,14 @@ retrieve section getsharedir n i = onError (RetrieveFailure . show) $ do -- Note that the contents of shares is never changed, so it's ok to set the -- mtime to the epoch; backup programs won't be confused. obscure :: Section -> GetShareDir -> IO ObscureResult -obscure section getsharedir = onError (ObscureFailure . show) $ do +obscure section getsharedir = onStorageError (ObscureFailure . show) $ do dir <- getsharedir section fs <- filter isShareFile <$> getDirectoryContents dir mapM_ (\f -> setFileTimes (dir </> f) 0 0) fs return ObscureSuccess count :: Section -> GetShareDir -> IO CountResult -count section getsharedir = onError (CountFailure . show) $ do +count section getsharedir = onStorageError (CountFailure . show) $ do dir <- getsharedir section exists <- doesDirectoryExist dir if exists @@ -156,11 +155,11 @@ move section getsharedir storage = do | share' == share -> movesuccess f _ -> return StoreAlreadyExists -onError :: (IOException -> a) -> IO a -> IO a -onError f = onError' (pure . f) +onStorageError :: (IOException -> a) -> IO a -> IO a +onStorageError f = onStorageError' (pure . f) -onError' :: (IOException -> IO a) -> IO a -> IO a -onError' f a = do +onStorageError' :: (IOException -> IO a) -> IO a -> IO a +onStorageError' f a = do v <- try a case v of Left e -> f e |