leave export logged as incomplete if initial renames fail

This way, the temp files that might be left due to failure will be
cleaned up next time.

Also, nub the list of incomplete exports to avoid repeatedly adding the
same tree to it when running export repeatedly when it's failing.

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2017-09-12 14:19:26 -04:00
parent 4d3a464e83
commit 8de516ad2c
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 8 additions and 5 deletions

View file

@ -10,6 +10,7 @@
module Command.Export where module Command.Export where
import Command import Command
import qualified Annex
import qualified Git import qualified Git
import qualified Git.DiffTree import qualified Git.DiffTree
import qualified Git.LsTree import qualified Git.LsTree
@ -144,10 +145,12 @@ seek o = do
-- Waiting until now to record the export guarantees that, -- Waiting until now to record the export guarantees that,
-- if this export is interrupted, there are no files left over -- if this export is interrupted, there are no files left over
-- from a previous export, that are not part of this export. -- from a previous export, that are not part of this export.
recordExport (uuid r) $ ExportChange c <- Annex.getState Annex.errcounter
{ oldTreeish = map exportedTreeish old when (c == 0) $
, newTreeish = new recordExport (uuid r) $ ExportChange
} { oldTreeish = map exportedTreeish old
, newTreeish = new
}
-- Export everything that is not yet exported. -- Export everything that is not yet exported.
(l, cleanup') <- inRepo $ Git.LsTree.lsTree new (l, cleanup') <- inRepo $ Git.LsTree.lsTree new

View file

@ -84,7 +84,7 @@ recordExportBeginning remoteuuid newtree = do
. M.lookup u . simpleMap . M.lookup u . simpleMap
. parseLogNew parseExportLog . parseLogNew parseExportLog
<$> Annex.Branch.get exportLog <$> Annex.Branch.get exportLog
let new = old { incompleteExportedTreeish = newtree:incompleteExportedTreeish old } let new = old { incompleteExportedTreeish = nub (newtree:incompleteExportedTreeish old) }
Annex.Branch.change exportLog $ Annex.Branch.change exportLog $
showLogNew formatExportLog showLogNew formatExportLog
. changeLog c u (ExportLog new remoteuuid) . changeLog c u (ExportLog new remoteuuid)