Skip to content

Commit

Permalink
commands.identify:cmd_identify_original - add --ignore-lock option to…
Browse files Browse the repository at this point in the history
… allow re-identification of files that have been locked
  • Loading branch information
MatteoCampinoti94 committed Jan 16, 2025
1 parent 60ff1d3 commit ee49866
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion digiarch/commands/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def identify_original_file(
parent: UUID | None,
original_path: str | PathLike | None,
*loggers: Logger,
ignore_lock: bool = False,
):
errors: list[Event] = []
existing_file: OriginalFile | None = db.original_files[
Expand All @@ -155,7 +156,7 @@ def identify_original_file(

if existing_file and not update:
return
if existing_file and existing_file.lock:
if existing_file and existing_file.lock and not ignore_lock:
return

file = OriginalFile.from_file(siegfried_file.filename, avid.path, parent=parent)
Expand Down Expand Up @@ -223,6 +224,7 @@ def identify_original_files(
update: bool,
parent: UUID | None,
*loggers: Logger,
ignore_lock: bool = False,
):
if not paths:
return
Expand All @@ -239,6 +241,7 @@ def identify_original_files(
parent,
None,
*loggers,
ignore_lock=ignore_lock,
)


Expand Down Expand Up @@ -367,6 +370,7 @@ def grp_identify():
)
@option("--exclude", type=str, multiple=True, help="File and folder names to exclude. [multiple]")
@option("--batch-size", type=IntRange(1), default=100, show_default=True, help="Amount of files to identify at a time.")
@option("--ignore-lock", is_flag=True, default=False, show_default=True, help="Re-identify locked files.")
@option_dry_run()
@pass_context
def cmd_identify_original(
Expand All @@ -379,6 +383,7 @@ def cmd_identify_original(
custom_signatures_file: str | None,
exclude: tuple[str, ...],
batch_size: int | None,
ignore_lock: bool,
dry_run: bool,
):
"""
Expand Down Expand Up @@ -427,6 +432,7 @@ def cmd_identify_original(
bool(query),
None,
log_stdout,
ignore_lock=ignore_lock,
)
if not dry_run:
db.commit()
Expand Down

0 comments on commit ee49866

Please sign in to comment.