diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-13 17:13:19 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-13 17:13:19 -0400 |
commit | 48e49d83867a5335f5e45a42dbac202caa42cd5d (patch) | |
tree | 2fb75ecd3295a0bb23d6eb393d9f0cf3ed4d663d /Storage | |
parent | 4d69e01dea8515d9cbccfbf2f793c98a1a752539 (diff) | |
download | keysafe-48e49d83867a5335f5e45a42dbac202caa42cd5d.tar.gz |
implemented dynamic rate limiting
Diffstat (limited to 'Storage')
-rw-r--r-- | Storage/Local.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Storage/Local.hs b/Storage/Local.hs index b9f0f3e..71d5aa7 100644 --- a/Storage/Local.hs +++ b/Storage/Local.hs @@ -3,7 +3,13 @@ - Licensed under the GNU AGPL version 3 or higher. -} -module Storage.Local (localStorage, storageDir, testStorageDir, uploadQueue) where +module Storage.Local + ( localStorage + , storageDir + , testStorageDir + , uploadQueue + , localDiskUsage + ) where import Types import Types.Storage @@ -22,6 +28,7 @@ import Raaz.Core.Encode import Control.DeepSeq import Control.Exception import Control.Monad +import System.DiskSpace type GetShareDir = Section -> IO FilePath @@ -127,6 +134,11 @@ storageDir (Just (LocalStorageDirectory d)) (Section section) = testStorageDir :: FilePath -> GetShareDir testStorageDir tmpdir = storageDir (Just (LocalStorageDirectory tmpdir)) +localDiskUsage :: Maybe LocalStorageDirectory -> IO DiskUsage +localDiskUsage lsd = do + dir <- storageDir lsd (Section ".") + getDiskUsage dir + -- | The takeFileName ensures that, if the StorableObjectIdent somehow -- contains a path (eg starts with "../" or "/"), it is not allowed -- to point off outside the shareDir. |