diff options
author | Joey Hess <joey@kitenet.net> | 2013-01-05 15:26:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-01-05 15:57:53 -0400 |
commit | b61c7206806d037de3e6c20beedebe5002c1a4aa (patch) | |
tree | a963608386b4bb08d772001cb3c4d281ba537f1e /Annex | |
parent | 71d1effb4f2b6224780afea37994713a6169baf8 (diff) |
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).
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/CatFile.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs index ffac4fccd..ab7cb2aef 100644 --- a/Annex/CatFile.hs +++ b/Annex/CatFile.hs @@ -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 |