import qualified Git.LsTree
import qualified Git.Types
import qualified Database.Keys
-import qualified Database.Keys.SQL
import Config
import qualified Utility.RawFilePath as R
-}
scanAnnexedFiles :: Annex ()
scanAnnexedFiles = whenM (inRepo Git.Ref.headExists <&&> not <$> isBareRepo) $ do
+ -- This gets the keys database populated with all annexed files,
+ -- by running Database.Keys.reconcileStaged.
+ 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. So, the rest of this makes another pass over the
+ -- tree to do that.
g <- Annex.gitRepo
- Database.Keys.runWriter $
- liftIO . Database.Keys.SQL.dropAllAssociatedFiles
(l, cleanup) <- inRepo $ Git.LsTree.lsTree
Git.LsTree.LsTreeRecursive
(Git.LsTree.LsTreeLong True)
add i isregfile k = do
let tf = Git.LsTree.file i
- Database.Keys.runWriter $
- liftIO . Database.Keys.SQL.addAssociatedFileFast k tf
whenM (pure isregfile <&&> inAnnex k) $ do
f <- fromRepo $ fromTopFilePath tf
liftIO (isPointerFile f) >>= \case
(asTopFilePath file)
(SQL.WriteHandle qh)
when (dstmode /= fmtTreeItemType TreeSymlink) $
- reconcilerace (asTopFilePath file) key
+ reconcilepointerfile (asTopFilePath file) key
return True
Nothing -> return False
procdiff mdfeeder rest
_ -> return conflicted -- parse failed
procmergeconflictdiff _ _ conflicted = return conflicted
- reconcilerace file key = do
+ reconcilepointerfile file key = do
caches <- liftIO $ SQL.getInodeCaches key (SQL.ReadHandle qh)
keyloc <- calcRepo (gitAnnexLocation key)
keypopulated <- sameInodeCache keyloc caches
where
af = SFilePath (getTopFilePath f)
--- Does not remove any old association for a file, but less expensive
--- than addAssociatedFile. Calling dropAllAssociatedFiles first and then
--- this is an efficient way to update all associated files.
-addAssociatedFileFast :: Key -> TopFilePath -> WriteHandle -> IO ()
-addAssociatedFileFast k f = queueDb $ void $ insertUnique $ Associated k af
- where
- af = SFilePath (getTopFilePath f)
-
-dropAllAssociatedFiles :: WriteHandle -> IO ()
-dropAllAssociatedFiles = queueDb $
- deleteWhere ([] :: [Filter Associated])
-
{- Note that the files returned were once associated with the key, but
- some of them may not be any longer. -}
getAssociatedFiles :: Key -> ReadHandle -> IO [TopFilePath]