summaryrefslogtreecommitdiffhomepage
path: root/Storage/Local.hs
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-02-17 08:37:05 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-02-17 08:37:05 -0700
commit0fc5c49d067747c97f6e774001df67b27a304983 (patch)
tree6e59b61894adf77a2fbaf8a257690a672dec6a90 /Storage/Local.hs
parentf9f821b71530dbcab61b96b589e6e87e8952e198 (diff)
parentde59756b62fdb8045217e3474f2528bcb48508ed (diff)
downloadkeysafe-0fc5c49d067747c97f6e774001df67b27a304983.tar.gz
Merge tag '0.20200214'
tagging package keysafe version 0.20200214 # gpg: Signature made Fri 14 Feb 2020 10:39:08 AM MST # gpg: using RSA key 28A500C35207EAB72F6C0F25DB12DB0FF05F8F38 # gpg: Good signature from "Joey Hess <joeyh@joeyh.name>" [full] # Primary key fingerprint: E85A 5F63 B31D 24C1 EBF0 D81C C910 D922 2512 E3C7 # Subkey fingerprint: 28A5 00C3 5207 EAB7 2F6C 0F25 DB12 DB0F F05F 8F38
Diffstat (limited to 'Storage/Local.hs')
-rw-r--r--Storage/Local.hs19
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