e60766543f
WIP: This is mostly complete, but there is a problem: createDirectoryUnder throws an error when annex.dbdir is set to outside the git repo. annex.dbdir is a workaround for filesystems where sqlite does not work, due to eg, the filesystem not properly supporting locking. It's intended to be set before initializing the repository. Changing it in an existing repository can be done, but would be the same as making a new repository and moving all the annexed objects into it. While the databases get recreated from the git-annex branch in that situation, any information that is in the databases but not stored in the branch gets lost. It may be that no information ever gets stored in the databases that cannot be reconstructed from the branch, but I have not verified that. Sponsored-by: Dartmouth College's Datalad project
46 lines
1.2 KiB
Haskell
46 lines
1.2 KiB
Haskell
{- git-annex smudge log file
|
|
-
|
|
- Copyright 2018 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Logs.Smudge where
|
|
|
|
import Annex.Common
|
|
import Git.FilePath
|
|
import Logs.File
|
|
|
|
import qualified Data.ByteString.Lazy as L
|
|
|
|
-- | Log a smudged file.
|
|
smudgeLog :: Key -> TopFilePath -> Annex ()
|
|
smudgeLog k f = do
|
|
logf <- fromRepo gitAnnexSmudgeLog
|
|
lckf <- fromRepo gitAnnexSmudgeLock
|
|
appendLogFile logf lckf $ L.fromStrict $
|
|
serializeKey' k <> " " <> getTopFilePath f
|
|
|
|
-- | Streams all smudged files, and then empties the log at the end.
|
|
--
|
|
-- If the action is interrupted or throws an exception, the log file is
|
|
-- left unchanged.
|
|
--
|
|
-- Locking is used to prevent new items being added to the log while this
|
|
-- is running.
|
|
streamSmudged :: (Key -> TopFilePath -> Annex ()) -> Annex ()
|
|
streamSmudged a = do
|
|
logf <- fromRepo gitAnnexSmudgeLog
|
|
lckf <- fromRepo gitAnnexSmudgeLock
|
|
streamLogFile (fromRawFilePath logf) lckf $ \l ->
|
|
case parse l of
|
|
Nothing -> noop
|
|
Just (k, f) -> a k f
|
|
where
|
|
parse l =
|
|
let (ks, f) = separate (== ' ') l
|
|
in do
|
|
k <- deserializeKey ks
|
|
return (k, asTopFilePath (toRawFilePath f))
|