From 845289fdd8fbbed2cbc7eaf7a3d31efe5a8aa80d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 18 Aug 2016 16:37:23 -0400 Subject: untested moving of upload queues on to servers There needs to be a 1:1 mapping between upload queues and servers, otherwise using the upload queue risks two shards for the same object being uploaded to the same server. Also, fixed storeShards to give up on StoreAlreadyExists, rather than trying another storage location. Otherwise, on a name collision, the shards would be rejected by the servers, and be stored to their upload queues. --- Types/Storage.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Types') diff --git a/Types/Storage.hs b/Types/Storage.hs index bc11b55..b3f714a 100644 --- a/Types/Storage.hs +++ b/Types/Storage.hs @@ -14,14 +14,21 @@ import Types newtype StorageLocations = StorageLocations [Storage] deriving (Monoid) +-- | Storage interface. This can be used both for local storage, +-- an upload queue, or a remote server. +-- +-- Note that there is no interface to enumerate shards. +-- This is intentional; servers should not allow that. data Storage = Storage { storeShard :: StorableObjectIdent -> Shard -> IO StoreResult , retrieveShard :: ShardNum -> StorableObjectIdent -> IO RetrieveResult , obscureShards :: IO ObscureResult - -- ^ run after making some calls to storeShard/retrieveShard, - -- to avoid correlation attacks + -- ^ Run after making some calls to storeShard/retrieveShard, + -- to avoid correlation attacks. , countShards :: IO CountResult - } -- Note that there is no interface to enumerate shards. + , moveShards :: Storage -> IO () + -- ^ Tries to move all shards from this storage to another one. + } data StoreResult = StoreSuccess | StoreAlreadyExists | StoreFailure String deriving (Show) -- cgit v1.2.3