-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast incremental file transfer using Merkle-Hash-Trees -- -- A command line tool that can be used to incrementally synchronize a -- directory hierarchy with a second one. It is using a Merkle-Hash-Tree -- to compare the folders, such that the synchronization time and -- communication (round) complexity grows only logarithmically with the -- size of the directories (assuming the actual difference of the -- directories is small). -- -- The communication happens through standard streams between parent and -- child processes, which can easily be routed through remote command -- execution tools. @package sync-mht @version 0.3.8.3 module Sync.MerkleTree.Util.GetFromInputStream -- | Deserialize value from inputstream getFromInputStream :: (Serial a) => InputStream ByteString -> IO a -- | This monad is used to increase the speed of communication between two -- processes - if there is latency. It works by using the -- non-deterministic part of the communication protocol to send multiple -- requests to the output-channel, before processing the responses from -- the input-channel. -- -- Considering the example -- --
-- foo = splitRequests [bar, baz] -- bar = do x <- request (GetSumOf 1 2) -- liftM Sum request (GetSumOf x 3) -- baz = liftM Sum request (GetSumOf 4 5) ---- -- running foo in the RequestMonad: -- --
-- runRequestMonad inputHandle outputHandle foo ---- -- will send both messages GetSumOf 1 2, GetSumOf 4 5, -- without having to wait for the repsonse to the first request. The last -- request GetSumOf 3 3 will be send after the response for the -- first message has arrived. module Sync.MerkleTree.Util.RequestMonad data RequestMonad b request :: (Serial a, Serial b) => a -> RequestMonad b -- | Run the provided request monad using the given communication channels runRequestMonad :: InputStream ByteString -> OutputStream ByteString -> RequestMonad b -> IO b -- | Combine results in the monad non-deterministically (it is required -- that the monoid is commutative) splitRequests :: (Monoid a) => [RequestMonad a] -> RequestMonad a instance Control.Monad.IO.Class.MonadIO Sync.MerkleTree.Util.RequestMonad.RequestMonad instance GHC.Base.Applicative Sync.MerkleTree.Util.RequestMonad.RequestMonad instance GHC.Base.Functor Sync.MerkleTree.Util.RequestMonad.RequestMonad instance GHC.Base.Monad Sync.MerkleTree.Util.RequestMonad.RequestMonad instance GHC.Base.Functor (Sync.MerkleTree.Util.RequestMonad.RequestMonadT Data.ByteString.Internal.ByteString) instance GHC.Base.Applicative (Sync.MerkleTree.Util.RequestMonad.RequestMonadT Data.ByteString.Internal.ByteString) instance GHC.Base.Monad (Sync.MerkleTree.Util.RequestMonad.RequestMonadT Data.ByteString.Internal.ByteString) instance Control.Monad.IO.Class.MonadIO (Sync.MerkleTree.Util.RequestMonad.RequestMonadT Data.ByteString.Internal.ByteString) module Sync.MerkleTree.Trie data Hash Hash :: !ByteString -> Hash [unHash] :: Hash -> !ByteString data Trie a Trie :: !Hash -> !(TrieNode a) -> Trie a [t_hash] :: Trie a -> !Hash [t_node] :: Trie a -> !(TrieNode a) data TrieNode a Node :: !(Array Int (Trie a)) -> TrieNode a Leave :: !(Set a) -> TrieNode a data NodeType NodeType :: NodeType LeaveType :: NodeType data TrieLocation TrieLocation :: !Int -> !Int -> TrieLocation -- | Must be nonnegative [tl_level] :: TrieLocation -> !Int -- | Must be between nonnegative and smaller than (degree^tl_level) [tl_index] :: TrieLocation -> !Int degree :: Int class HasDigest a digest :: HasDigest a => a -> Digest MD5 -- | Fingerprint of a Merkle-Hash-Tree node We asssume the Tree below a -- node is identical while synchronizing if its FingerPrint is data Fingerprint Fingerprint :: !Hash -> !NodeType -> Fingerprint [f_hash] :: Fingerprint -> !Hash [f_nodeType] :: Fingerprint -> !NodeType toFingerprint :: Trie a -> Fingerprint -- | Creates a Merkle-Hash-Tree for a list of elements mkTrie :: (Ord a, HasDigest a) => Int -> [a] -> Trie a mkNode :: (Array Int (Trie a)) -> Trie a hashMD5 :: ByteString -> Digest MD5 combineHash :: [Hash] -> Hash -- | The function groupOf x eeturns a value between 0 to degree-1 -- for a digest with the property that groupOf forms an -- approximate unviversal hash familiy. groupOf :: (HasDigest a) => Int -> a -> Int mkLeave :: (HasDigest a, Ord a) => [a] -> Trie a lookup :: (Monad m) => Trie a -> TrieLocation -> m (Trie a) queryHash :: (Monad m) => Trie a -> TrieLocation -> m Fingerprint querySet :: (Ord a, Monad m) => Trie a -> TrieLocation -> m (Set a) getAll :: (Ord a) => Trie a -> Set a rootLocation :: TrieLocation expand :: TrieLocation -> (Array Int (Trie a)) -> [(TrieLocation, Trie a)] newtype TestDigest TestDigest :: Text -> TestDigest [unTestDigest] :: TestDigest -> Text tests :: Test instance GHC.Generics.Selector Sync.MerkleTree.Trie.S1_0_1Fingerprint instance GHC.Generics.Selector Sync.MerkleTree.Trie.S1_0_0Fingerprint instance GHC.Generics.Constructor Sync.MerkleTree.Trie.C1_0Fingerprint instance GHC.Generics.Datatype Sync.MerkleTree.Trie.D1Fingerprint instance GHC.Generics.Selector Sync.MerkleTree.Trie.S1_0_1TrieLocation instance GHC.Generics.Selector Sync.MerkleTree.Trie.S1_0_0TrieLocation instance GHC.Generics.Constructor Sync.MerkleTree.Trie.C1_0TrieLocation instance GHC.Generics.Datatype Sync.MerkleTree.Trie.D1TrieLocation instance GHC.Generics.Constructor Sync.MerkleTree.Trie.C1_1NodeType instance GHC.Generics.Constructor Sync.MerkleTree.Trie.C1_0NodeType instance GHC.Generics.Datatype Sync.MerkleTree.Trie.D1NodeType instance GHC.Generics.Selector Sync.MerkleTree.Trie.S1_0_0Hash instance GHC.Generics.Constructor Sync.MerkleTree.Trie.C1_0Hash instance GHC.Generics.Datatype Sync.MerkleTree.Trie.D1Hash instance GHC.Show.Show Sync.MerkleTree.Trie.TestDigest instance GHC.Classes.Ord Sync.MerkleTree.Trie.TestDigest instance GHC.Classes.Eq Sync.MerkleTree.Trie.TestDigest instance GHC.Generics.Generic Sync.MerkleTree.Trie.Fingerprint instance GHC.Classes.Eq Sync.MerkleTree.Trie.Fingerprint instance GHC.Generics.Generic Sync.MerkleTree.Trie.TrieLocation instance GHC.Generics.Generic Sync.MerkleTree.Trie.NodeType instance GHC.Classes.Eq Sync.MerkleTree.Trie.NodeType instance GHC.Classes.Eq a => GHC.Classes.Eq (Sync.MerkleTree.Trie.Trie a) instance GHC.Show.Show a => GHC.Show.Show (Sync.MerkleTree.Trie.Trie a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Sync.MerkleTree.Trie.TrieNode a) instance GHC.Show.Show a => GHC.Show.Show (Sync.MerkleTree.Trie.TrieNode a) instance GHC.Generics.Generic Sync.MerkleTree.Trie.Hash instance GHC.Classes.Eq Sync.MerkleTree.Trie.Hash instance GHC.Show.Show Sync.MerkleTree.Trie.Hash instance Data.Bytes.Serial.Serial Sync.MerkleTree.Trie.Hash instance Data.Bytes.Serial.Serial Sync.MerkleTree.Trie.NodeType instance Data.Bytes.Serial.Serial Sync.MerkleTree.Trie.TrieLocation instance Data.Bytes.Serial.Serial Sync.MerkleTree.Trie.Fingerprint instance Sync.MerkleTree.Trie.HasDigest Sync.MerkleTree.Trie.TestDigest module Sync.MerkleTree.Types -- | Information about a file that we expect to change, when the contents -- change. data File File :: Path -> FileSize -> FileModTime -> File [f_name] :: File -> Path [f_size] :: File -> FileSize [f_modtime] :: File -> FileModTime data Entry FileEntry :: File -> Entry DirectoryEntry :: Path -> Entry newtype FileSize FileSize :: Int64 -> FileSize [unFileSize] :: FileSize -> Int64 data FileModTime FileModTime :: !Int64 -> FileModTime [unModTime] :: FileModTime -> !Int64 -- | Representation for paths below the synchronization root directory data Path Root :: Path Path :: Text -> Path -> Path -- | Returns the string representation of a path toFilePath :: FilePath -> Path -> FilePath -- | Entries are sorted first according to their depth in the path which is -- useful for directory operations -- | Return the depth of an entries path levelOf :: Entry -> Int instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_1Entry instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_0Entry instance GHC.Generics.Datatype Sync.MerkleTree.Types.D1Entry instance GHC.Generics.Selector Sync.MerkleTree.Types.S1_0_2File instance GHC.Generics.Selector Sync.MerkleTree.Types.S1_0_1File instance GHC.Generics.Selector Sync.MerkleTree.Types.S1_0_0File instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_0File instance GHC.Generics.Datatype Sync.MerkleTree.Types.D1File instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_1Path instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_0Path instance GHC.Generics.Datatype Sync.MerkleTree.Types.D1Path instance GHC.Generics.Selector Sync.MerkleTree.Types.S1_0_0FileModTime instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_0FileModTime instance GHC.Generics.Datatype Sync.MerkleTree.Types.D1FileModTime instance GHC.Generics.Selector Sync.MerkleTree.Types.S1_0_0FileSize instance GHC.Generics.Constructor Sync.MerkleTree.Types.C1_0FileSize instance GHC.Generics.Datatype Sync.MerkleTree.Types.D1FileSize instance GHC.Generics.Generic Sync.MerkleTree.Types.Entry instance GHC.Classes.Eq Sync.MerkleTree.Types.Entry instance GHC.Generics.Generic Sync.MerkleTree.Types.File instance GHC.Classes.Ord Sync.MerkleTree.Types.File instance GHC.Classes.Eq Sync.MerkleTree.Types.File instance GHC.Generics.Generic Sync.MerkleTree.Types.Path instance GHC.Classes.Ord Sync.MerkleTree.Types.Path instance GHC.Classes.Eq Sync.MerkleTree.Types.Path instance GHC.Generics.Generic Sync.MerkleTree.Types.FileModTime instance GHC.Classes.Ord Sync.MerkleTree.Types.FileModTime instance GHC.Classes.Eq Sync.MerkleTree.Types.FileModTime instance GHC.Num.Num Sync.MerkleTree.Types.FileSize instance GHC.Generics.Generic Sync.MerkleTree.Types.FileSize instance GHC.Classes.Ord Sync.MerkleTree.Types.FileSize instance GHC.Classes.Eq Sync.MerkleTree.Types.FileSize instance Data.Bytes.Serial.Serial Sync.MerkleTree.Types.File instance Data.Bytes.Serial.Serial Sync.MerkleTree.Types.Entry instance Data.Bytes.Serial.Serial Sync.MerkleTree.Types.FileSize instance Data.Bytes.Serial.Serial Sync.MerkleTree.Types.FileModTime instance Data.Bytes.Serial.Serial Sync.MerkleTree.Types.Path instance GHC.Classes.Ord Sync.MerkleTree.Types.Entry instance Sync.MerkleTree.Trie.HasDigest Sync.MerkleTree.Types.Entry module Sync.MerkleTree.CommTypes class Monad m => Protocol m queryHashReq :: Protocol m => TrieLocation -> m Fingerprint querySetReq :: Protocol m => TrieLocation -> m (Set Entry) logReq :: Protocol m => Text -> m Bool queryFileReq :: Protocol m => Path -> m QueryFileResponse queryFileContReq :: Protocol m => ContHandle -> m QueryFileResponse terminateReq :: Protocol m => Maybe Text -> m Bool queryTime :: Protocol m => m UTCTime data ContHandle ContHandle :: Int -> ContHandle data ClientServerOptions ClientServerOptions :: Bool -> Bool -> Bool -> [FilePath] -> Maybe (Double, Double) -> ClientServerOptions [cs_add] :: ClientServerOptions -> Bool [cs_update] :: ClientServerOptions -> Bool [cs_delete] :: ClientServerOptions -> Bool [cs_ignore] :: ClientServerOptions -> [FilePath] [cs_compareClocks] :: ClientServerOptions -> Maybe (Double, Double) data Request QuerySet :: TrieLocation -> Request QueryHash :: TrieLocation -> Request Log :: Text -> Request QueryFile :: Path -> Request QueryFileCont :: ContHandle -> Request Terminate :: (Maybe Text) -> Request QueryTime :: Request data QueryFileResponse Final :: QueryFileResponse ToBeContinued :: ByteString -> ContHandle -> QueryFileResponse data ProtocolVersion ProtocolVersion :: !Int -> ProtocolVersion thisProtocolVersion :: ProtocolVersion data LaunchMessage LaunchMessage :: ProtocolVersion -> FilePath -> Side -> ClientServerOptions -> LaunchMessage [lm_protocolVersion] :: LaunchMessage -> ProtocolVersion [lm_dir] :: LaunchMessage -> FilePath [lm_side] :: LaunchMessage -> Side [lm_clientServerOptions] :: LaunchMessage -> ClientServerOptions data Side Server :: Side Client :: Side instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_1QueryFileResponse instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_0QueryFileResponse instance GHC.Generics.Datatype Sync.MerkleTree.CommTypes.D1QueryFileResponse instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_6Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_5Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_4Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_3Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_2Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_1Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_0Request instance GHC.Generics.Datatype Sync.MerkleTree.CommTypes.D1Request instance GHC.Generics.Constructor Sync.MerkleTree.CommTypes.C1_0ContHandle instance GHC.Generics.Datatype Sync.MerkleTree.CommTypes.D1ContHandle instance GHC.Show.Show Sync.MerkleTree.CommTypes.LaunchMessage instance GHC.Read.Read Sync.MerkleTree.CommTypes.LaunchMessage instance GHC.Show.Show Sync.MerkleTree.CommTypes.Side instance GHC.Read.Read Sync.MerkleTree.CommTypes.Side instance GHC.Classes.Eq Sync.MerkleTree.CommTypes.ProtocolVersion instance GHC.Show.Show Sync.MerkleTree.CommTypes.ProtocolVersion instance GHC.Read.Read Sync.MerkleTree.CommTypes.ProtocolVersion instance GHC.Generics.Generic Sync.MerkleTree.CommTypes.QueryFileResponse instance GHC.Generics.Generic Sync.MerkleTree.CommTypes.Request instance GHC.Show.Show Sync.MerkleTree.CommTypes.ClientServerOptions instance GHC.Read.Read Sync.MerkleTree.CommTypes.ClientServerOptions instance GHC.Generics.Generic Sync.MerkleTree.CommTypes.ContHandle instance Data.Bytes.Serial.Serial Sync.MerkleTree.CommTypes.ContHandle instance Data.Bytes.Serial.Serial Sync.MerkleTree.CommTypes.Request instance Data.Bytes.Serial.Serial Sync.MerkleTree.CommTypes.QueryFileResponse module Sync.MerkleTree.Client data Diff a Diff :: (Set a) -> (Set a) -> Diff a showText :: (Show a) => a -> Text dataSize :: (Foldable f) => f Entry -> FileSize dataSizeText :: (Foldable f) => f Entry -> Text class (Protocol m, MonadIO m) => ClientMonad m split :: (ClientMonad m, Monoid a) => [m a] -> m a logClient :: (Protocol m) => Text -> m () data SimpleEntry FileSimpleEntry :: Path -> SimpleEntry DirectorySimpleEntry :: Path -> SimpleEntry analyseEntries :: Diff Entry -> ([Entry], [Entry], [Entry]) data Progress Progress :: IORef FileSize -> IORef Int -> IORef UTCTime -> Progress [pg_size] :: Progress -> IORef FileSize [pg_count] :: Progress -> IORef Int [pg_last] :: Progress -> IORef UTCTime checkClockDiff :: (ClientMonad m) => ClientServerOptions -> m (Maybe Text) abstractClient :: (ClientMonad m) => ClientServerOptions -> FilePath -> Trie Entry -> m (Maybe Text) syncClient :: (ClientMonad m) => ClientServerOptions -> FilePath -> Trie Entry -> m (Maybe Text) _CONCURRENT_FILETRANSFER_SIZE_ :: Int splitEvery :: Int -> [a] -> [[a]] syncNewOrChangedEntries :: (ClientMonad m) => Progress -> FilePath -> [Entry] -> m () showProgess :: (ClientMonad m) => Progress -> m () synchronizeNewOrChangedEntry :: (ClientMonad m) => Progress -> FilePath -> Entry -> m () nodeReq :: (ClientMonad m) => (TrieLocation, Trie Entry) -> m (Diff Entry) testEntry :: Test instance GHC.Classes.Ord Sync.MerkleTree.Client.SimpleEntry instance GHC.Classes.Eq Sync.MerkleTree.Client.SimpleEntry instance GHC.Classes.Ord a => GHC.Base.Monoid (Sync.MerkleTree.Client.Diff a) module Sync.MerkleTree.Server data ServerState ServerState :: Map Int Handle -> Int -> Trie Entry -> FilePath -> ServerState -- | Map of open file handles with their ids [st_handles] :: ServerState -> Map Int Handle -- | Next available id [st_nextHandle] :: ServerState -> Int -- | Merkle Hash Tree of server file hierarchy [st_trie] :: ServerState -> Trie Entry -- | path of the root of the file hierarchy [st_path] :: ServerState -> FilePath type ServerMonad = StateT ServerState IO startServerState :: FilePath -> Trie Entry -> IO ServerState -- | Respond to a queryFile or queryFileCont request for a given file -- handle and id withHandle :: Handle -> Int -> ServerMonad QueryFileResponse instance Sync.MerkleTree.CommTypes.Protocol Sync.MerkleTree.Server.ServerMonad module Sync.MerkleTree.Analyse -- | Returns all files and directories below the given FilePath analyse :: FilePath -> [String] -> IO [Entry] -- | Returns True if the given string is not "." or ".." isRealFile :: String -> Bool module Sync.MerkleTree.Sync child :: MVar () -> StreamPair -> IO () local :: ClientServerOptions -> FilePath -> FilePath -> IO (Maybe Text) parent :: StreamPair -> FilePath -> FilePath -> Direction -> ClientServerOptions -> IO (Maybe Text) openStreams :: Handle -> Handle -> IO StreamPair mkChanStreams :: IO (InputStream ByteString, OutputStream ByteString) data StreamPair StreamPair :: InputStream ByteString -> OutputStream ByteString -> StreamPair [sp_in] :: StreamPair -> InputStream ByteString [sp_out] :: StreamPair -> OutputStream ByteString data Direction FromRemote :: Direction ToRemote :: Direction tests :: Test instance Sync.MerkleTree.CommTypes.Protocol Sync.MerkleTree.Util.RequestMonad.RequestMonad instance Sync.MerkleTree.Client.ClientMonad Sync.MerkleTree.Util.RequestMonad.RequestMonad instance Sync.MerkleTree.Client.ClientMonad Sync.MerkleTree.Server.ServerMonad module Sync.MerkleTree.Run data RemoteCmd RemoteCmd :: String -> RemoteCmd Simulate :: RemoteCmd data SyncOptions SyncOptions :: Maybe FilePath -> Maybe FilePath -> Maybe RemoteCmd -> [String] -> [FilePath] -> Bool -> Bool -> Bool -> Bool -> [String] -> Maybe (Double, Double) -> Bool -> SyncOptions [so_source] :: SyncOptions -> Maybe FilePath [so_destination] :: SyncOptions -> Maybe FilePath [so_remote] :: SyncOptions -> Maybe RemoteCmd [so_ignore] :: SyncOptions -> [String] [so_boring] :: SyncOptions -> [FilePath] [so_add] :: SyncOptions -> Bool [so_update] :: SyncOptions -> Bool [so_delete] :: SyncOptions -> Bool [so_help] :: SyncOptions -> Bool [so_nonOptions] :: SyncOptions -> [String] [so_compareClocks] :: SyncOptions -> Maybe (Double, Double) [so_version] :: SyncOptions -> Bool defaultSyncOptions :: SyncOptions toClientServerOptions :: SyncOptions -> IO ClientServerOptions optDescriptions :: [OptDescr (SyncOptions -> SyncOptions)] parseNonOption :: String -> (SyncOptions -> SyncOptions) toSyncOptions :: [(SyncOptions -> SyncOptions)] -> SyncOptions putError :: String -> IO () printUsageInfo :: String -> IO () data Location Remote :: FilePath -> Location Local :: FilePath -> Location parseFilePath :: FilePath -> Location main :: String -> [String] -> IO () run :: String -> SyncOptions -> IO (Maybe Text) _WAIT_FOR_INPUT_ :: Int runChild :: IO () runParent :: ClientServerOptions -> RemoteCmd -> FilePath -> FilePath -> Direction -> IO (Maybe Text)