Skip to content

Commit b6f20ee

Browse files
kbabertsky
andauthored
ocrd_cli: but do check for existing output files
Co-authored-by: Robert Sachunsky <38561704+bertsky@users.noreply.github.com>
1 parent 914a010 commit b6f20ee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/dinglehopper/ocrd_cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ def process_page_file(self, *input_files: Optional[OcrdFileType]) -> None:
5959
[".html", "text/html"],
6060
[".json", "application/json"],
6161
]:
62+
output_file_id = file_id + report_suffix
63+
output_file = next(self.workspace.mets.find_files(ID=output_file_id), None)
64+
if output_file and config.OCRD_EXISTING_OUTPUT != 'OVERWRITE':
65+
raise FileExistsError(f"A file with ID=={output_file_id} already exists {output_file} and neither force nor ignore are set")
6266
self.workspace.add_file(
63-
file_id=file_id + report_suffix,
67+
file_id=output_file_id,
6468
file_grp=self.output_file_grp,
6569
page_id=page_id,
6670
mimetype=mimetype,

0 commit comments

Comments
 (0)