summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-10-24 12:39:35 -0400
committerJoey Hess <joeyh@joeyh.name>2016-10-24 12:39:35 -0400
commitd4d8dd66c305951d59069fa31c26855ea61b9322 (patch)
tree8d3b3457cb4c5b1c72883b8d18fa674803c747b8
parent758d6bbc4f98853d517eb092f507f62fa9f2d223 (diff)
downloadkeysafe-d4d8dd66c305951d59069fa31c26855ea61b9322.tar.gz
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.
-rw-r--r--CHANGELOG2
-rw-r--r--Storage/Local.hs7
2 files changed, 7 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 877b176..099715a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@ keysafe (0.20161023) UNRELEASED; urgency=medium
* The third keysafe server is now available, provided by Purism.
* Change default for --port to 4242.
+ * Fix --check-server to not fail when the server has not had anything
+ stored on it yet.
-- Joey Hess <id@joeyh.name> Sun, 23 Oct 2016 15:30:02 -0400
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