Treat manual storage as Importarr-owned
Use SAB storage under the configured download root as ownership even when SAB reports category '*'.
This commit is contained in:
+14
-8
@@ -31,21 +31,27 @@ def classify_history_item(item: dict[str, Any], active_nzo_ids: set[str], catego
|
||||
if not force_status and nzo_id and nzo_id in active_nzo_ids:
|
||||
return Readiness("processing", "SAB job is still present in queue")
|
||||
item_category = str(item.get("category") or item.get("cat") or "")
|
||||
if item_category != category:
|
||||
return Readiness("ignored", "SAB category is not owned by Importarr")
|
||||
status = str(item.get("status") or "")
|
||||
storage_value = str(item.get("storage") or "")
|
||||
storage = Path(storage_value).resolve() if storage_value else None
|
||||
root = download_root.resolve()
|
||||
storage_in_root = bool(storage and (storage == root or root in storage.parents))
|
||||
if item_category != category and not storage_in_root:
|
||||
return Readiness("ignored", "SAB category/storage is not owned by Importarr", storage)
|
||||
if not force_status and status == "Failed":
|
||||
return Readiness("failed", "SAB history reports failure")
|
||||
if not force_status and (status in NOT_READY_STATUSES or status != "Completed"):
|
||||
return Readiness("processing", f"SAB status is {status or 'unknown'}")
|
||||
storage_value = str(item.get("storage") or "")
|
||||
if not storage_value:
|
||||
if storage is None:
|
||||
return Readiness("unknown", "SAB completed item has no final storage")
|
||||
storage = Path(storage_value).resolve()
|
||||
root = download_root.resolve()
|
||||
if storage != root and root not in storage.parents:
|
||||
if not storage_in_root:
|
||||
return Readiness("ignored", "SAB storage is outside configured download root", storage)
|
||||
if has_transient_part(storage):
|
||||
return Readiness("processing", "SAB storage path contains transient unpack/admin marker", storage)
|
||||
reason = "forced despite SAB status" if force_status and status != "Completed" else "SAB completed in owned category with final storage"
|
||||
if force_status and status != "Completed":
|
||||
reason = "forced despite SAB status"
|
||||
elif item_category != category:
|
||||
reason = "SAB completed inside Importarr download root"
|
||||
else:
|
||||
reason = "SAB completed in owned category with final storage"
|
||||
return Readiness("ready", reason, storage)
|
||||
|
||||
Reference in New Issue
Block a user