From 188cb6942a43b033d4ac8e233955522dd36a70f2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Sep 2016 12:03:04 -0400 Subject: avoid crashing when moving from local storage directory that does not exist --- Storage/Local.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Storage') 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 -- cgit v1.2.3