import: update location log for removed files
This commit is contained in:
parent
5402c39882
commit
1c8793691a
3 changed files with 35 additions and 14 deletions
|
@ -30,6 +30,7 @@ import qualified Annex
|
||||||
import Annex.Link
|
import Annex.Link
|
||||||
import Annex.LockFile
|
import Annex.LockFile
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
|
import Annex.Export
|
||||||
import Backend
|
import Backend
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Types.KeySource
|
import Types.KeySource
|
||||||
|
@ -115,7 +116,8 @@ buildImportCommit remote importtreeconfig importcommitconfig importable =
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
Just finalcommit -> do
|
Just finalcommit -> do
|
||||||
updateexportdb finaltree
|
updateexportdb finaltree
|
||||||
updateexportlog finaltree
|
oldexport <- updateexportlog finaltree
|
||||||
|
updatelocationlog oldexport finaltree
|
||||||
return (Just finalcommit)
|
return (Just finalcommit)
|
||||||
|
|
||||||
mkcommits origtree basecommit (History importedtree hs) = do
|
mkcommits origtree basecommit (History importedtree hs) = do
|
||||||
|
@ -145,11 +147,33 @@ buildImportCommit remote importtreeconfig importcommitconfig importable =
|
||||||
Export.closeDb db
|
Export.closeDb db
|
||||||
|
|
||||||
updateexportlog importedtree = do
|
updateexportlog importedtree = do
|
||||||
old <- getExport (Remote.uuid remote)
|
oldexport <- getExport (Remote.uuid remote)
|
||||||
recordExport (Remote.uuid remote) $ ExportChange
|
recordExport (Remote.uuid remote) $ ExportChange
|
||||||
{ oldTreeish = exportedTreeishes old
|
{ oldTreeish = exportedTreeishes oldexport
|
||||||
, newTreeish = importedtree
|
, newTreeish = importedtree
|
||||||
}
|
}
|
||||||
|
return oldexport
|
||||||
|
|
||||||
|
-- downloadImport takes care of updating the location log
|
||||||
|
-- for the local repo when keys are downloaded, and also updates
|
||||||
|
-- the location log for the remote for keys that are present in it.
|
||||||
|
-- That leaves updating the location log for the remote for keys
|
||||||
|
-- that have had the last copy of their content removed from it.
|
||||||
|
--
|
||||||
|
-- This must run after the export database has been updated
|
||||||
|
-- and flushed to disk, so it can query it.
|
||||||
|
updatelocationlog oldexport finaltree = do
|
||||||
|
let stillpresent db k = liftIO $ not . null
|
||||||
|
<$> Export.getExportedLocation db k
|
||||||
|
let updater db oldkey _newkey _ = case oldkey of
|
||||||
|
Just (AnnexKey k) -> unlessM (stillpresent db k) $
|
||||||
|
logChange k (Remote.uuid remote) InfoMissing
|
||||||
|
Just (GitKey _) -> noop
|
||||||
|
Nothing -> noop
|
||||||
|
db <- Export.openDb (Remote.uuid remote)
|
||||||
|
forM_ (exportedTreeishes oldexport) $ \oldtree ->
|
||||||
|
Export.runExportDiffUpdater updater db oldtree finaltree
|
||||||
|
Export.closeDb db
|
||||||
|
|
||||||
data History t = History t [History t]
|
data History t = History t [History t]
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
|
@ -34,6 +34,8 @@ module Database.Export (
|
||||||
ExportTreeId,
|
ExportTreeId,
|
||||||
ExportTreeCurrentId,
|
ExportTreeCurrentId,
|
||||||
ExportUpdateResult(..),
|
ExportUpdateResult(..),
|
||||||
|
ExportDiffUpdater,
|
||||||
|
runExportDiffUpdater,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Database.Types
|
import Database.Types
|
||||||
|
|
|
@ -10,22 +10,17 @@ this.
|
||||||
|
|
||||||
## implementation notes
|
## implementation notes
|
||||||
|
|
||||||
|
* directory special remote import is prototype, does not notice modified
|
||||||
|
files, not race safe
|
||||||
|
|
||||||
|
* Need to support annex-tracking-branch configuration, which documentation
|
||||||
|
says makes git-annex sync and assistant do imports.
|
||||||
|
|
||||||
* need to check if a remote has importtree=yes before trying to import from it
|
* need to check if a remote has importtree=yes before trying to import from it
|
||||||
|
|
||||||
* export needs to use storeExportWithContentIdentifierM for importtree=yes
|
* export needs to use storeExportWithContentIdentifierM for importtree=yes
|
||||||
remotes
|
remotes
|
||||||
|
|
||||||
* Importing from a remote updates the location log for downloaded keys to
|
|
||||||
indicate they're present in the remote. So it should also update the
|
|
||||||
location log for keys that were present in the remote, but no longer are.
|
|
||||||
|
|
||||||
Plan: Diff the old and new export trees. For each removed file,
|
|
||||||
look up the key, and check with getExportedLocation if that key
|
|
||||||
is located on the remote (which it could be if it was moved or there were
|
|
||||||
multiple copies). If not, remove from location log. This will need to
|
|
||||||
be done after the export database has been updated and the update flushed
|
|
||||||
to disk.
|
|
||||||
|
|
||||||
* "git annex import master --from rmt" followed by "git annex import master:sub --from rmt"
|
* "git annex import master --from rmt" followed by "git annex import master:sub --from rmt"
|
||||||
first makes the tracking branch contain only what's in the remote,
|
first makes the tracking branch contain only what's in the remote,
|
||||||
and then grafts what's in the remote into a subdir. Is that the behavior
|
and then grafts what's in the remote into a subdir. Is that the behavior
|
||||||
|
|
Loading…
Reference in a new issue