remove second pass in scanAnnexedFiles
The pass was needed to populate files when annex.thin was set,
but in commit 73e0cbbb19
,
reconcileStaged started to do that. So, this second pass is not needed
any longer.
This commit is contained in:
parent
c912e7c4fd
commit
748addbe05
4 changed files with 11 additions and 86 deletions
|
@ -135,7 +135,7 @@ initialize' mversion = checkInitializeAllowed $ do
|
||||||
then configureSmudgeFilter
|
then configureSmudgeFilter
|
||||||
else deconfigureSmudgeFilter
|
else deconfigureSmudgeFilter
|
||||||
unlessM isBareRepo $ do
|
unlessM isBareRepo $ do
|
||||||
scanAnnexedFiles True
|
scanAnnexedFiles
|
||||||
hookWrite postCheckoutHook
|
hookWrite postCheckoutHook
|
||||||
hookWrite postMergeHook
|
hookWrite postMergeHook
|
||||||
AdjustedBranch.checkAdjustedClone >>= \case
|
AdjustedBranch.checkAdjustedClone >>= \case
|
||||||
|
|
|
@ -8,24 +8,10 @@
|
||||||
module Annex.WorkTree where
|
module Annex.WorkTree where
|
||||||
|
|
||||||
import Annex.Common
|
import Annex.Common
|
||||||
import qualified Annex
|
|
||||||
import Annex.Link
|
import Annex.Link
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
import Annex.Content
|
|
||||||
import Annex.ReplaceFile
|
|
||||||
import Annex.CurrentBranch
|
import Annex.CurrentBranch
|
||||||
import Annex.InodeSentinal
|
|
||||||
import Utility.InodeCache
|
|
||||||
import Git.FilePath
|
|
||||||
import Git.CatFile
|
|
||||||
import qualified Git.Ref
|
|
||||||
import qualified Git.LsTree
|
|
||||||
import qualified Git.Types
|
|
||||||
import qualified Database.Keys
|
import qualified Database.Keys
|
||||||
import Config
|
|
||||||
import qualified Utility.RawFilePath as R
|
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as L
|
|
||||||
|
|
||||||
{- Looks up the key corresponding to an annexed file in the work tree,
|
{- Looks up the key corresponding to an annexed file in the work tree,
|
||||||
- by examining what the file links to.
|
- by examining what the file links to.
|
||||||
|
@ -69,74 +55,13 @@ ifAnnexed file yes no = maybe no yes =<< lookupKey file
|
||||||
|
|
||||||
{- Find all annexed files and update the keys database for them.
|
{- Find all annexed files and update the keys database for them.
|
||||||
-
|
-
|
||||||
- This is expensive, and so normally the associated files are updated
|
- Normally the keys database is updated incrementally when it's being
|
||||||
- incrementally when changes are noticed. So, this only needs to be done
|
- opened, and changes are noticed. Calling this explicitly allows
|
||||||
- when initializing/upgrading a repository.
|
- running the update at an earlier point.
|
||||||
-
|
|
||||||
- Also, the content for an unlocked file may already be present as
|
|
||||||
- an annex object. If so, populate the pointer file with it.
|
|
||||||
- But if worktree file does not have a pointer file's content, it is left
|
|
||||||
- as-is.
|
|
||||||
-}
|
-}
|
||||||
scanAnnexedFiles :: Bool -> Annex ()
|
scanAnnexedFiles :: Annex ()
|
||||||
scanAnnexedFiles initscan = do
|
scanAnnexedFiles =
|
||||||
-- This gets the keys database populated with all annexed files,
|
-- All that needs to be done is to open the database,
|
||||||
-- by running Database.Keys.reconcileStaged.
|
-- that will result in Database.Keys.reconcileStaged
|
||||||
|
-- running, and doing the work.
|
||||||
Database.Keys.runWriter (const noop)
|
Database.Keys.runWriter (const noop)
|
||||||
-- The above tries to populate pointer files, but one thing it
|
|
||||||
-- is not able to handle is populating a pointer file when the
|
|
||||||
-- annex object file already exists, but its inode is not yet
|
|
||||||
-- cached and annex.thin is set. So, the rest of this makes
|
|
||||||
-- another pass over the tree to do that.
|
|
||||||
whenM
|
|
||||||
( pure initscan
|
|
||||||
<&&> annexThin <$> Annex.getGitConfig
|
|
||||||
<&&> inRepo Git.Ref.headExists
|
|
||||||
<&&> not <$> isBareRepo
|
|
||||||
) $ do
|
|
||||||
g <- Annex.gitRepo
|
|
||||||
(l, cleanup) <- inRepo $ Git.LsTree.lsTree
|
|
||||||
Git.LsTree.LsTreeRecursive
|
|
||||||
(Git.LsTree.LsTreeLong True)
|
|
||||||
Git.Ref.headRef
|
|
||||||
catObjectStreamLsTree l want g go
|
|
||||||
liftIO $ void cleanup
|
|
||||||
where
|
|
||||||
-- Want to process symlinks, and regular files.
|
|
||||||
want i = case Git.Types.toTreeItemType (Git.LsTree.mode i) of
|
|
||||||
Just Git.Types.TreeSymlink -> Just (i, False)
|
|
||||||
Just Git.Types.TreeFile -> checkfilesize i
|
|
||||||
Just Git.Types.TreeExecutable -> checkfilesize i
|
|
||||||
_ -> Nothing
|
|
||||||
|
|
||||||
-- Avoid processing files that are too large to be pointer files.
|
|
||||||
checkfilesize i = case Git.LsTree.size i of
|
|
||||||
Just n | n < maxPointerSz -> Just (i, True)
|
|
||||||
_ -> Nothing
|
|
||||||
|
|
||||||
go getnext = liftIO getnext >>= \case
|
|
||||||
Just ((i, isregfile), Just c) -> do
|
|
||||||
maybe noop (add i isregfile)
|
|
||||||
(parseLinkTargetOrPointer (L.toStrict c))
|
|
||||||
go getnext
|
|
||||||
_ -> return ()
|
|
||||||
|
|
||||||
add i isregfile k = do
|
|
||||||
let tf = Git.LsTree.file i
|
|
||||||
whenM (pure isregfile <&&> inAnnex k) $ do
|
|
||||||
f <- fromRepo $ fromTopFilePath tf
|
|
||||||
liftIO (isPointerFile f) >>= \case
|
|
||||||
Just k' | k' == k -> do
|
|
||||||
destmode <- liftIO $ catchMaybeIO $
|
|
||||||
fileMode <$> R.getFileStatus f
|
|
||||||
ic <- replaceWorkTreeFile (fromRawFilePath f) $ \tmp -> do
|
|
||||||
let tmp' = toRawFilePath tmp
|
|
||||||
linkFromAnnex' k tmp' destmode >>= \case
|
|
||||||
LinkAnnexOk ->
|
|
||||||
withTSDelta (liftIO . genInodeCache tmp')
|
|
||||||
LinkAnnexNoop -> return Nothing
|
|
||||||
LinkAnnexFailed -> liftIO $ do
|
|
||||||
writePointerFile tmp' k destmode
|
|
||||||
return Nothing
|
|
||||||
maybe noop (restagePointerFile (Restage True) f) ic
|
|
||||||
_ -> noop
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ update = do
|
||||||
-- point to refresh the keys database for changes to annexed files.
|
-- point to refresh the keys database for changes to annexed files.
|
||||||
-- Doing it explicitly here avoids a later pause in the middle of
|
-- Doing it explicitly here avoids a later pause in the middle of
|
||||||
-- some other action.
|
-- some other action.
|
||||||
scanAnnexedFiles False
|
scanAnnexedFiles
|
||||||
updateSmudged (Restage True)
|
updateSmudged (Restage True)
|
||||||
stop
|
stop
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ upgrade automatic = flip catchNonAsync onexception $ do
|
||||||
, do
|
, do
|
||||||
checkGitVersionForIndirectUpgrade
|
checkGitVersionForIndirectUpgrade
|
||||||
)
|
)
|
||||||
scanAnnexedFiles True
|
scanAnnexedFiles
|
||||||
configureSmudgeFilter
|
configureSmudgeFilter
|
||||||
-- Inode sentinal file was only used in direct mode and when
|
-- Inode sentinal file was only used in direct mode and when
|
||||||
-- locking down files as they were added. In v6, it's used more
|
-- locking down files as they were added. In v6, it's used more
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue