add "--multi-user" support

This commit is contained in:
bigcat88
2025-08-27 19:47:55 +03:00
parent 7c1b0be496
commit 026b7f209c
5 changed files with 136 additions and 56 deletions

View File

@@ -2,8 +2,12 @@ import os
from pathlib import Path
from typing import Optional, Literal, Sequence
import sqlalchemy as sa
import folder_paths
from .database.models import AssetInfo
def get_comfy_models_folders() -> list[tuple[str, list[str]]]:
"""Build a list of (folder_name, base_paths[]) categories that are configured for model locations.
@@ -133,3 +137,11 @@ def ensure_within_base(candidate: str, base: str) -> None:
raise ValueError("destination escapes base directory")
except Exception:
raise ValueError("invalid destination path")
def visible_owner_clause(owner_id: str) -> sa.sql.ClauseElement:
"""Build owner visibility predicate for reads."""
owner_id = (owner_id or "").strip()
if owner_id == "":
return AssetInfo.owner_id == ""
return AssetInfo.owner_id.in_(["", owner_id])