assistant: Make expensive transfer scan work fully in direct mode.

The expensive scan uses lookupFile, but in direct mode, that doesn't work
for files that are present. So the scan was not finding things that are
present that need to be uploaded. (It did find things not present that
needed to be downloaded.)

Now lookupFile also works in direct mode. Note that it still prefers
symlinks on disk to info committed to git, in direct mode. This is
necessary to make things like Assistant.Threads.Watcher.onAddSymlink
work correctly, when given a new symlink not yet checked into git (or
replacing a file checked into git).
This commit is contained in:
Joey Hess 2013-01-05 15:26:22 -04:00
parent 15ecce2bfd
commit 1cdf2b923d
5 changed files with 38 additions and 11 deletions

View file

@ -9,8 +9,9 @@ module Annex.CatFile (
catFile,
catObject,
catObjectDetails,
catFileHandle,
catKey,
catFileHandle
catKeyFile,
) where
import qualified Data.ByteString.Lazy as L
@ -46,4 +47,16 @@ catFileHandle = maybe startup return =<< Annex.getState Annex.catfilehandle
{- From the Sha or Ref of a symlink back to the key. -}
catKey :: Ref -> Annex (Maybe Key)
catKey ref = fileKey . takeFileName . encodeW8 . L.unpack <$> catObject ref
catKey ref = do
l <- encodeW8 . L.unpack <$> catObject ref
return $ if isLinkToAnnex l
then fileKey $ takeFileName l
else Nothing
{- From a file in git back to the key.
-
- Prefixing the file with ./ makes this work even if in a subdirectory
- of a repo.
-}
catKeyFile :: FilePath -> Annex (Maybe Key)
catKeyFile f = catKey $ Ref $ ":./" ++ f