avoid exporting non-annexed symlinks

So that importing does not replace them with plain files.

This works similarly to how the previous handling of submodules and
matchers did, except that annexed symlinks still get exported as plain
files of course, it's only non-annexed symlinks that it does not make sense
to export.

When symlinks have previously been exported, updating the export will
unexport them after upgrading to this commit.

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2022-01-03 14:21:50 -04:00
parent 0584e096d1
commit 7e2f5edd68
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 29 additions and 7 deletions

View file

@ -479,7 +479,8 @@ removeEmptyDirectories r db loc ks
newtype ExportFiltered t = ExportFiltered t
-- | Filters the tree to annexed files that are preferred content of the
-- remote, and also including non-annexed files, but not submodules.
-- remote, and also including non-annexed files, but not submodules or
-- non-annexed symlinks.
--
-- A log is written with tree items that were filtered out, so they can
-- be added back in when importing from the remote.
@ -505,17 +506,28 @@ filterExport r tree = logExportExcluded (uuid r) $ \logwriter -> do
case toTreeItemType mode of
-- Don't export submodule entries.
Just TreeSubmodule -> excluded
_ -> case mmatcher of
Nothing -> return (Just ti)
Just matcher -> catKey sha >>= \case
Just k -> checkmatcher matcher k
-- Always export non-annexed files.
Nothing -> return (Just ti)
Just TreeSymlink -> checkkey True
_ -> checkkey False
where
excluded = do
() <- liftIO $ logwriter ti
return Nothing
checkkey issymlink =
case mmatcher of
Nothing
| issymlink -> catKey sha >>= \case
Just _ -> return (Just ti)
Nothing
| issymlink -> excluded
| otherwise -> return (Just ti)
| otherwise -> return (Just ti)
Just matcher -> catKey sha >>= \case
Just k -> checkmatcher matcher k
Nothing
| issymlink -> excluded
| otherwise -> return (Just ti)
checkmatcher matcher k = do
let mi = MatchingInfo $ ProvidedInfo
{ providedFilePath = Just $