avoid sync/assistant drop from appendonly

Make git-annex sync and the assistant skip trying to drop from appendonly
remotes since it's just going to fail.

git-annex drop and similar commands will still try to drop from
appendonly, so the user will see failure messages when they try to do
that. To do otherwise would be confusing since the user has explicitly
asked for a drop with those commands.

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2018-08-30 11:23:57 -04:00
parent 8b39db20b5
commit 76f32012af
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 9 additions and 5 deletions

View file

@ -11,7 +11,7 @@ import Annex.Common
import qualified Annex import qualified Annex
import Logs.Trust import Logs.Trust
import Annex.NumCopies import Annex.NumCopies
import Types.Remote (uuid) import Types.Remote (uuid, appendonly)
import qualified Remote import qualified Remote
import qualified Command.Drop import qualified Command.Drop
import Command import Command
@ -29,6 +29,9 @@ type Reason = String
{- Drop a key from local and/or remote when allowed by the preferred content {- Drop a key from local and/or remote when allowed by the preferred content
- and numcopies settings. - and numcopies settings.
- -
- Skips trying to drop from remotes that are appendonly, since those drops
- would presumably fail.
-
- The UUIDs are ones where the content is believed to be present. - The UUIDs are ones where the content is believed to be present.
- The Remote list can include other remotes that do not have the content; - The Remote list can include other remotes that do not have the content;
- only ones that match the UUIDs will be dropped from. - only ones that match the UUIDs will be dropped from.
@ -58,9 +61,10 @@ handleDropsFrom locs rs reason fromhere key afile preverified runner = do
AssociatedFile (Just f) -> nub (f : l) AssociatedFile (Just f) -> nub (f : l)
AssociatedFile Nothing -> l AssociatedFile Nothing -> l
n <- getcopies fs n <- getcopies fs
let rs' = filter (not . appendonly) rs
void $ if fromhere && checkcopies n Nothing void $ if fromhere && checkcopies n Nothing
then go fs rs n >>= dropl fs then go fs rs' n >>= dropl fs
else go fs rs n else go fs rs' n
where where
getcopies fs = do getcopies fs = do
(untrusted, have) <- trustPartition UnTrusted locs (untrusted, have) <- trustPartition UnTrusted locs

View file

@ -285,10 +285,10 @@ cleanupUnexport r ea db eks loc = do
removeExportedLocation db (asKey ek) loc removeExportedLocation db (asKey ek) loc
flushDbQueue db flushDbQueue db
-- A readonly remote can support removeExportLocation to remove -- An appendonly remote can support removeExportLocation to remove
-- the file from the exported tree, but still retain the content -- the file from the exported tree, but still retain the content
-- and allow retrieving it. -- and allow retrieving it.
unless (Remote.readonly) $ do unless (appendonly r) $ do
remaininglocs <- liftIO $ remaininglocs <- liftIO $
concat <$> forM eks (\ek -> getExportedLocation db (asKey ek)) concat <$> forM eks (\ek -> getExportedLocation db (asKey ek))
when (null remaininglocs) $ when (null remaininglocs) $