diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-07 15:22:01 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-07 15:35:36 -0400 |
commit | ee0c34c8f2f94775b39ef10ed580cab47d2f929c (patch) | |
tree | 8b1b26a7f379d85f4658003a5e8a72559d009fcc /Backend.hs | |
parent | 42a370de0544e65fc1f150d3b2406b6683b7e5e1 (diff) |
support pointer files
Backend.lookupFile is changed to always fall back to catKey when
operating on a file that's not a symlink.
catKey is changed to understand pointer files, as well as annex symlinks.
Before, catKey needed a file mode witness, to be sure it was looking at a
symlink. That was complicated stuff. Now, it doesn't actually care if a
file in git is a symlink or not; in either case asking git for the content
of the file will get the pointer to the key.
This does mean that git-annex will treat a link
foo -> WORM--bar as a git-annex file, and also treats
a regular file containing annex/objects/WORM--bar as a git-annex file.
Calling catKey could make git-annex commands need to do more work than
before. This would especially be the case if a repo contained many regular
files, and only a few annexed files, as now git-annex will need to ask
git about the contents of the regular files.
Diffstat (limited to 'Backend.hs')
-rw-r--r-- | Backend.hs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Backend.hs b/Backend.hs index 922d0c2a7..28f83c7e0 100644 --- a/Backend.hs +++ b/Backend.hs @@ -26,7 +26,6 @@ import Annex.Link import Types.Key import Types.KeySource import qualified Types.Backend as B -import Config -- When adding a new backend, import it here and add it to the list. import qualified Backend.Hash @@ -81,22 +80,17 @@ genKey' (b:bs) source = do {- Looks up the key corresponding to an annexed file, - by examining what the file links to. - - - In direct mode, there is often no link on disk, in which case - - the symlink is looked up in git instead. However, a real link - - on disk still takes precedence over what was committed to git in direct - - mode. + - An unlocked file will not have a link on disk, so fall back to + - looking for a pointer to a key in git. -} lookupFile :: FilePath -> Annex (Maybe Key) lookupFile file = do mkey <- isAnnexLink file case mkey of Just key -> makeret key - Nothing -> ifM isDirect - ( maybe (return Nothing) makeret =<< catKeyFile file - , return Nothing - ) + Nothing -> maybe (return Nothing) makeret =<< catKeyFile file where - makeret k = return $ Just k + makeret = return . Just getBackend :: FilePath -> Key -> Annex (Maybe Backend) getBackend file k = let bname = keyBackendName k in |