hashed-storage-0.3.9: Hashed file storage support code.




data Format Source

On-disk format for object storage: we implement a completely loose format (one file per object), a compact format stored in a single append-only file and an immutable pack format.




looseLookup :: OS -> Hash -> IO (Maybe FileSegment)Source

data Block Source

Object storage block. When used as a hatchery, the loose or compact format are preferable, while for mature space, the pack format is more useful.




blockLookup :: Hash -> IO (Maybe FileSegment)
size :: Int
format :: Format

data OS Source

Object storage. Contains a single hatchery and possibly a number of mature space blocks, usually in form of packs. It also keeps a list of root pointers and has a way to extract pointers from objects (externally supplied). These last two things are used to implement a simple GC.




hatchery :: Block
mature :: [Block]
roots :: [Hash]
references :: FileSegment -> IO [Hash]
rootdir :: FilePath

repack :: OS -> Set Hash -> IO OSSource

Reduce number of packs in the object storage. This may both recombine packs to eliminate dead objects and join some packs to form bigger packs. The set of hashes given is used as roots for GC marking.

hatch :: OS -> [ByteString] -> IO OSSource

Add new objects to the object storage (i.e. put them into hatchery). It is safe to call this even on objects that are already present in the storage: such objects will be skipped.

compact :: OS -> IO OSSource

Reduce hatchery size by moving things into packs.

blocksLookup :: [Block] -> Hash -> IO (Maybe (Hash, FileSegment))Source

lookup :: OS -> Hash -> IO (Maybe FileSegment)Source

create :: FilePath -> Format -> IO OSSource

Create an empty object storage in given directory, with a hatchery of given format. The directory is created if needed, but is assumed to be empty.

createPack :: OS -> [(Hash, FileSegment)] -> IO BlockSource

live :: OS -> [Block] -> IO (Map Hash FileSegment)Source

Build a map of live objects (i.e. those reachable from the given roots) in a given list of Blocks.

readPackedDarcsPristine :: OS -> Hash -> IO TreeSource

Read a Tree in the darcs hashed format from an object storage. This is basically the same as readDarcsHashed from Storage.Hashed, but uses an object storage instead of traditional darcs filesystem layout. Requires the tree root hash as a starting point.

writePackedDarcsPristine :: Tree -> OS -> IO (OS, Hash)Source

Write a Tree into an object storage, using the darcs-style directory formatting (and therefore darcs-style hashes). Gives back the object storage and the root hash of the stored Tree. NB. The function expects that the Tree comes equipped with darcs-style hashes already!

darcsPristineRefs :: FileSegment -> IO [Hash]Source