Skip to content

Commit

Permalink
backtrack pbars after failing when adding nonexistent files
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Jan 26, 2020
1 parent 7fa5e69 commit 61a1e7f
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions dvc/repo/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from . import locked
from dvc.exceptions import RecursiveAddingWhileUsingFilename
from dvc.output.base import OutputDoesNotExistError
from dvc.progress import Tqdm
from dvc.repo.scm_context import scm_context
from dvc.stage import Stage
Expand Down Expand Up @@ -50,18 +51,24 @@ def add(repo, targets, recursive=False, no_commit=False, fname=None):

repo.check_modified_graph(stages)

for stage in Tqdm(
stages,
with Tqdm(
total=len(stages),
desc="Processing",
unit="file",
disable=True if len(stages) == 1 else None,
):
stage.save()

if not no_commit:
stage.commit()

stage.dump()
) as pbar_stages:
for stage in stages:
try:
stage.save()
except OutputDoesNotExistError:
pbar.n -= 1
raise

if not no_commit:
stage.commit()

stage.dump()
pbar_stages.update()

stages_list += stages

Expand Down

0 comments on commit 61a1e7f

Please sign in to comment.