diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-22 12:03:04 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-22 12:03:04 -0400 |
commit | 188cb6942a43b033d4ac8e233955522dd36a70f2 (patch) | |
tree | 586b9a2ece411a0c772a250cd047bf9cf3729e48 /Storage | |
parent | 9eeb584342d1f29415065efc5ba34a7045b2259b (diff) | |
download | keysafe-188cb6942a43b033d4ac8e233955522dd36a70f2.tar.gz |
avoid crashing when moving from local storage directory that does not exist
Diffstat (limited to 'Storage')
-rw-r--r-- | Storage/Local.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Storage/Local.hs b/Storage/Local.hs index 99b92db..e061831 100644 --- a/Storage/Local.hs +++ b/Storage/Local.hs @@ -15,6 +15,7 @@ import Types import Types.Storage import Serialization () import Utility.UserInfo +import Utility.Exception import qualified Data.ByteString as B import qualified Data.ByteString.UTF8 as U8 import Data.Monoid @@ -26,9 +27,9 @@ import System.Posix import System.FilePath import Raaz.Core.Encode import Control.DeepSeq -import Control.Exception import Control.Monad import System.DiskSpace +import Control.Exception (IOException) type GetShareDir = Section -> IO FilePath @@ -99,7 +100,7 @@ count section getsharedir = onError (CountFailure . show) $ do move :: Section -> GetShareDir -> Storage -> IO [StoreResult] move section getsharedir storage = do dir <- getsharedir section - fs <- map (dir </>) <$> getDirectoryContents dir + fs <- map (dir </>) <$> catchDefaultIO [] (getDirectoryContents dir) rs <- forM fs $ \f -> case fromShareFile f of Nothing -> return Nothing Just i -> Just <$> go f i |