diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-31 14:30:35 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-31 14:33:22 -0400 |
commit | 019c080687ce4a07031bdfe2263397f4f868c3c3 (patch) | |
tree | 187c7abb67ce1c0bc126a48501de4e7ed3e1f7e0 /Storage | |
parent | 176dbd5798a7def03ea6c61713a0c216ab1e1674 (diff) | |
download | keysafe-019c080687ce4a07031bdfe2263397f4f868c3c3.tar.gz |
added --store-directory
Diffstat (limited to 'Storage')
-rw-r--r-- | Storage/Local.hs | 14 | ||||
-rw-r--r-- | Storage/Network.hs | 6 |
2 files changed, 11 insertions, 9 deletions
diff --git a/Storage/Local.hs b/Storage/Local.hs index d0a1d15..38fc5b7 100644 --- a/Storage/Local.hs +++ b/Storage/Local.hs @@ -3,7 +3,7 @@ - Licensed under the GNU AGPL version 3 or higher. -} -module Storage.Local (localStorage, userStorageDir, testStorageDir, uploadQueue) where +module Storage.Local (localStorage, storageDir, testStorageDir, uploadQueue) where import Types import Types.Storage @@ -38,8 +38,8 @@ localStorage getsharedir n = Storage where section = Section n -uploadQueue :: Server -> Storage -uploadQueue s = localStorage userStorageDir ("uploadqueue" </> serverName s) +uploadQueue :: Maybe LocalStorageDirectory -> Server -> Storage +uploadQueue d s = localStorage (storageDir d) ("uploadqueue" </> serverName s) store :: Section -> GetShareDir -> StorableObjectIdent -> Share -> IO StoreResult store section getsharedir i s = onError (StoreFailure . show) $ do @@ -117,13 +117,15 @@ onError f a = do Left e -> f e Right r -> r -userStorageDir :: GetShareDir -userStorageDir (Section section) = do +storageDir :: Maybe LocalStorageDirectory -> GetShareDir +storageDir Nothing (Section section) = do u <- getUserEntryForID =<< getEffectiveUserID return $ homeDirectory u </> dotdir </> section +storageDir (Just (LocalStorageDirectory d)) (Section section) = + pure $ d </> section testStorageDir :: FilePath -> GetShareDir -testStorageDir tmpdir (Section section) = pure $ tmpdir </> section +testStorageDir tmpdir = storageDir (Just (LocalStorageDirectory tmpdir)) -- | The takeFileName ensures that, if the StorableObjectIdent somehow -- contains a path (eg starts with "../" or "/"), it is not allowed diff --git a/Storage/Network.hs b/Storage/Network.hs index 356f5ad..d16d693 100644 --- a/Storage/Network.hs +++ b/Storage/Network.hs @@ -42,9 +42,9 @@ serverUrl srv = BaseUrl Http (serverName srv) (serverPort srv) "" -- Using tor is highly recommended, to avoid correlation attacks. networkServers :: IO [Server] networkServers = return - [ Server "localhost" 8080 - , Server "localhost" 8080 - , Server "localhost" 8080 + [ Server "localhost" 4242 + , Server "localhost" 4242 + , Server "localhost" 4242 ] networkStorage :: Server -> Storage |