From d083843a1f668cf1081b3fd90e390c36698ac604 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 14 Feb 2020 13:12:26 -0400 Subject: 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. --- Storage/Local.hs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'Storage') 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 -- cgit v1.2.3