From d4d8dd66c305951d59069fa31c26855ea61b9322 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 24 Oct 2016 12:39:35 -0400 Subject: Fix --check-server to not fail when the server has not had anything stored on it yet. Threw an exception because the share directory was not created yet. This commit was sponsored by Anthony DeRobertis on Patreon. --- Storage/Local.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Storage') diff --git a/Storage/Local.hs b/Storage/Local.hs index 637a31b..c1dcea4 100644 --- a/Storage/Local.hs +++ b/Storage/Local.hs @@ -112,8 +112,11 @@ obscure section getsharedir = onError (ObscureFailure . show) $ do count :: Section -> GetShareDir -> IO CountResult count section getsharedir = onError (CountFailure . show) $ do dir <- getsharedir section - CountResult . genericLength . filter isShareFile - <$> getDirectoryContents dir + exists <- doesDirectoryExist dir + if exists + then CountResult . genericLength . filter isShareFile + <$> getDirectoryContents dir + else return (CountResult 0) move :: Section -> GetShareDir -> Storage -> IO [StoreResult] move section getsharedir storage = do -- cgit v1.2.3