Enhance error reporting for deleted files

The code now checks if a requested file is present in the files list before diagnosing issues and generating error reports for it. It will help prevent attempting to diagnose or report on files that do not exist or deleted, thus enhancing efficiency and preventing possible error generation

CURA-10903
This commit is contained in:
Saumya Jain 2024-04-10 14:50:26 +02:00
parent a965392559
commit c6ff0d3030
2 changed files with 9 additions and 8 deletions

View file

@ -35,5 +35,5 @@ class Directory(Linter):
def checkFilesDeleted(self) -> Iterator[GitComment]: def checkFilesDeleted(self) -> Iterator[GitComment]:
if not self._file.exists(): if not self._file.exists():
""" Check if there is a file that is deleted, this causes upgrade scripts to not work properly """ """ Check if there is a file that is deleted, this causes upgrade scripts to not work properly """
yield GitComment( f"File: {self._file} must not be deleted as it is not allowed. It will create issues upgrading Cura" ) yield GitComment( f'File: **{self._file}** must not be deleted as it is not allowed. It will create issues upgrading Cura' )
yield yield

View file

@ -51,15 +51,16 @@ def main() -> None:
if args.deleted: if args.deleted:
for file in args.Files: for file in args.Files:
deletedFiles = diagnoseIssuesWithFile(file, settings ) if file not in files:
comments_check["Error Files"].extend([d.toDict() for d in deletedFiles]) deletedFiles = diagnoseIssuesWithFile(file, settings)
comments_check["Error Files"].extend([d.toDict() for d in deletedFiles])
results = yaml.dump(comments_check, default_flow_style=False, indent=4, width=240) results = yaml.dump(comments_check, default_flow_style=False, indent=4, width=240)
if report: if report:
report.write_text(results) report.write_text(results)
else: else:
print(results) print(results)
if to_fix or to_diagnose: if to_fix or to_diagnose:
for file in files: for file in files: