"""
mark_synology_x_odpad.py — Označí Tower1/#ColdData/SynologyMaly/Public/X/
jako odpad (skenovaná série publikací e0xxx, 3744x5616, bez EXIF).
Potvrzeno uživatelem přes náhled.

wanted=FALSE, category='Odpad-sken'
"""
import sys
import psycopg2

sys.stdout.reconfigure(encoding="utf-8")

DB = dict(host="192.168.1.76", port=5432, user="vladimir.buzalka",
          password="Vlado7309208104++", database="fotky_buzalkovi")

conn = psycopg2.connect(**DB)
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()

cur.execute("""
    UPDATE photos p
    SET wanted = FALSE, category = 'Odpad-sken'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id = z.id
      AND z.cesta_zalohy LIKE %s
      AND p.category IS DISTINCT FROM 'Odpad-sken'
""", ('/mnt/user/ZalohaVsechObrazku/Tower1/#ColdData/SynologyMaly/Public/X/%',))

print(f"SynologyMaly/Public/X -> Odpad-sken: {cur.rowcount:,} řádků")
conn.close()
