Skip to content

Commit 7bc9deb

Browse files
committed
Make collection of non-existent files more clear
(DIS-962)
1 parent 0f8c210 commit 7bc9deb

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

acquire/collector.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ def collect_path(
341341
path = self.target.fs.path(path)
342342

343343
try:
344+
# If a path does not exist, is_dir(), is_file() and is_symlink() will return False (and not raise an
345+
# exception), so we need to explicitly check for this.
346+
exists = self.target.fs.lexists(path)
344347
is_dir = path.is_dir()
345348
is_file = path.is_file()
346349
is_symlink = path.is_symlink()
@@ -360,19 +363,23 @@ def collect_path(
360363
self.report.add_path_failed(module_name, path)
361364
return
362365

363-
if is_dir:
364-
self.collect_dir(path, seen_paths=seen_paths, module_name=module_name)
365-
elif is_file:
366-
self.collect_file(path, module_name=module_name)
367-
elif is_symlink:
368-
log.error(
369-
"- Can't collect %s (symlink to %s) in module %s",
370-
path,
371-
path.get().readlink(),
372-
module_name,
373-
)
366+
if exists:
367+
if is_dir:
368+
self.collect_dir(path, seen_paths=seen_paths, module_name=module_name)
369+
elif is_file:
370+
self.collect_file(path, module_name=module_name)
371+
elif is_symlink:
372+
log.error(
373+
"- Can't collect %s (symlink to %s) in module %s",
374+
path,
375+
path.get().readlink(),
376+
module_name,
377+
)
378+
else:
379+
log.error("- Don't know how to collect %s in module %s", path, module_name)
374380
else:
375-
log.error("- Don't know how to collect %s in module %s", path, module_name)
381+
self.report.add_path_missing(module_name, path)
382+
log.error("- Path %s is not found", path)
376383

377384
def collect_command_output(
378385
self,

0 commit comments

Comments
 (0)