darcs-2.18.5: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Util.Cache

Synopsis

- data Cache
- mkCache :: [CacheLoc] -> Cache
- mkDirCache :: FilePath -> Cache
- mkRepoCache :: FilePath -> Cache
- cacheEntries :: Cache -> [CacheLoc]
- data CacheType
  - = Repo
  - | Directory
- data CacheLoc = Cache {
  - cacheType :: !CacheType
  - cacheWritable :: !WritableOrNot
  - cacheSource :: !String
  }
- data WritableOrNot
  - = Writable
  - | NotWritable
- data HashedDir
  - = HashedPristineDir
  - | HashedPatchesDir
  - | HashedInventoriesDir
- hashedDir :: HashedDir -> FilePath
- bucketFolder :: FilePath -> FilePath
- filterRemoteCaches :: Cache -> IO Cache
- cleanCaches :: Cache -> HashedDir -> IO ()
- cleanCachesWithHint :: Cache -> HashedDir -> [String] -> IO ()
- fetchFileUsingCache :: ValidHash h => Cache -> h -> IO (FilePath, ByteString)
- speculateFileUsingCache :: ValidHash h => Cache -> h -> IO ()
- speculateFilesUsingCache :: ValidHash h => Cache -> [h] -> IO ()
- writeFileUsingCache :: ValidHash h => Cache -> ByteString -> IO h
- peekInCache :: ValidHash h => Cache -> h -> IO Bool
- parseCacheLoc :: String -> Maybe CacheLoc
- showCacheLoc :: CacheLoc -> String
- writable :: CacheLoc -> Bool
- isThisRepo :: CacheLoc -> Bool
- hashedFilePath :: CacheLoc -> HashedDir -> FilePath -> FilePath
- allHashedDirs :: [HashedDir]
- reportBadSources :: IO ()
- closestWritableDirectory :: Cache -> Maybe String
- dropNonRepos :: Cache -> Cache

# Documentation

data Cache #

Cache is an abstract type for hiding the underlying cache locations

#### Instances

Instances details

Show Cache # |
Instance details Defined in Darcs.Util.Cache Methods showsPrec :: Int -> Cache -> ShowS # show :: Cache -> String # showList :: [Cache] -> ShowS #

mkCache :: [CacheLoc] -> Cache #

Smart constructor for `Cache`.

mkDirCache :: FilePath -> Cache #

mkRepoCache :: FilePath -> Cache #

cacheEntries :: Cache -> [CacheLoc] #

data CacheType #

Constructors

Repo |
Directory |

#### Instances

Instances details

Show CacheType # |
Instance details Defined in Darcs.Util.Cache Methods showsPrec :: Int -> CacheType -> ShowS # show :: CacheType -> String # showList :: [CacheType] -> ShowS #
Eq CacheType # |
Instance details Defined in Darcs.Util.Cache Methods (==) :: CacheType -> CacheType -> Bool # (/=) :: CacheType -> CacheType -> Bool #

data CacheLoc #

Constructors

Cache |
Fields cacheType :: !CacheType cacheWritable :: !WritableOrNot cacheSource :: !String

#### Instances

Instances details

Eq CacheLoc # | Note: this non-structural instance ignores the `cacheWritable` field. This is so that when we `nub` a list of locations we retain only one (the first) variant.
Instance details Defined in Darcs.Util.Cache Methods (==) :: CacheLoc -> CacheLoc -> Bool # (/=) :: CacheLoc -> CacheLoc -> Bool #

data WritableOrNot #

Constructors

Writable |
NotWritable |

#### Instances

Instances details

Show WritableOrNot # |
Instance details Defined in Darcs.Util.Cache Methods showsPrec :: Int -> WritableOrNot -> ShowS # show :: WritableOrNot -> String # showList :: [WritableOrNot] -> ShowS #
Eq WritableOrNot # |
Instance details Defined in Darcs.Util.Cache Methods (==) :: WritableOrNot -> WritableOrNot -> Bool # (/=) :: WritableOrNot -> WritableOrNot -> Bool #

data HashedDir #

Semantically, this is the type of hashed objects. Git has a type tag inside the hashed file itself, whereas in Darcs the type is determined by the subdirectory.

Constructors

HashedPristineDir |
HashedPatchesDir |
HashedInventoriesDir |

#### Instances

Instances details

Eq HashedDir # |
Instance details Defined in Darcs.Util.ValidHash Methods (==) :: HashedDir -> HashedDir -> Bool # (/=) :: HashedDir -> HashedDir -> Bool #

hashedDir :: HashedDir -> FilePath #

bucketFolder :: FilePath -> FilePath #

filterRemoteCaches :: Cache -> IO Cache #

Filter caches for remote repos. This affects only entries that are locally valid paths (i.e. not network URLs): they are removed if non-existent, or demoted to NotWritable if they are not actually writable in the file system.

cleanCaches :: Cache -> HashedDir -> IO () #

cleanCachesWithHint :: Cache -> HashedDir -> [String] -> IO () #

fetchFileUsingCache :: ValidHash h => Cache -> h -> IO (FilePath, ByteString) #

`fetchFileUsingCache cache dir hash` receives a list of caches `cache`, the directory for which that file belongs `dir` and the `hash` of the file to fetch. It tries to fetch the file from one of the sources, trying them in order one by one. If the file cannot be fetched from any of the sources, this operation fails. Otherwise we return the path where we found the file and its content.

speculateFileUsingCache :: ValidHash h => Cache -> h -> IO () #

Add pipelined downloads to the (low-priority) queue, for the rest it is a noop.

speculateFilesUsingCache :: ValidHash h => Cache -> [h] -> IO () #

Do `speculateFilesUsingCache` for files not already in a writable cache position.

writeFileUsingCache :: ValidHash h => Cache -> ByteString -> IO h #

Write file content, except if it is already in the cache, in which case merely create a hard link to that file. The returned value is the size and hash of the content.

peekInCache :: ValidHash h => Cache -> h -> IO Bool #

Return whether the `Cache` contains a file with the given hash in a writable position.

parseCacheLoc :: String -> Maybe CacheLoc #

showCacheLoc :: CacheLoc -> String #

writable :: CacheLoc -> Bool #

isThisRepo :: CacheLoc -> Bool #

hashedFilePath :: CacheLoc -> HashedDir -> FilePath -> FilePath #

The full filepath of a simple file name inside a given `CacheLoc` under `HashedDir`.

allHashedDirs :: [HashedDir] #

reportBadSources :: IO () #

Prints an error message with a list of bad caches.

closestWritableDirectory :: Cache -> Maybe String #

dropNonRepos :: Cache -> Cache #

This keeps only `Repo` `NotWritable` entries.