Skip to content

Commit 5379aa2

Browse files
authored
add: raise DoesNotExistError only if the output path does not exist (#10373)
`dvc add` command incorrectly raises a `DoesNotExistError` when a broken symlink exists in an output directory, and the target name is same as the directory's name. eg: If `data` is an output, and is the command is invoked as `dvc add data` (i.e. no virtual directory operations to perform). The expected behavior to raise a `FileNotFoundError`. `DoesNotExistError` should only be raised if the output itself does not exist. Related: #3717
1 parent 3375a7c commit 5379aa2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dvc/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ def add( # noqa: C901
13651365
dry_run=not self.use_cache,
13661366
)
13671367
except FileNotFoundError as exc:
1368-
if self.fs_path == path:
1368+
if not self.exists:
13691369
raise self.DoesNotExistError(self) from exc
13701370
if not self.is_dir_checksum:
13711371
raise

0 commit comments

Comments
 (0)