Delete the currently logged-in admin account (keeps files).
()
| 12292 | conn = db_connect() |
| 12293 | conn.execute("INSERT INTO file_activity(owner, actor, action, relpath, detail, created_at) VALUES(?,?,?,?,?,?)", (owner, actor or owner, action, safe_relpath(relpath), str(detail or "")[:2000], now_z())) |
| 12294 | # Keep a useful history without allowing the SQLite table to grow forever. |
| 12295 | conn.execute("DELETE FROM file_activity WHERE owner=? AND id NOT IN (SELECT id FROM file_activity WHERE owner=? ORDER BY id DESC LIMIT 5000)", (owner, owner)) |
| 12296 | conn.commit(); conn.close() |
| 12297 | except Exception: |
| 12298 | pass |
| 12299 | |
| 12300 | |
| 12301 | def _delete_file_metadata(owner: str, relpath: str) -> None: |
| 12302 | relpath = safe_relpath(relpath) |
| 12303 | like = relpath + "/%" |
| 12304 | with FILE_META_LOCK: |
| 12305 | conn = db_connect() |
| 12306 | conn.execute("DELETE FROM file_comments WHERE owner=? AND (relpath=? OR relpath LIKE ?)", (owner, relpath, like)) |
| 12307 | conn.execute("UPDATE file_shares SET revoked=1 WHERE owner=? AND (relpath=? OR relpath LIKE ?)", (owner, relpath, like)) |
| 12308 | conn.commit(); conn.close() |
| 12309 | |
| 12310 | |
| 12311 | def _remap_file_metadata(owner: str, old_rel: str, new_rel: str) -> None: |
| 12312 | old_rel, new_rel = safe_relpath(old_rel), safe_relpath(new_rel) |
| 12313 | with FILE_META_LOCK: |
| 12314 | conn = db_connect() |
| 12315 | for table in ("file_comments", "file_shares"): |
| 12316 | rows = conn.execute(f"SELECT id, relpath FROM {table} WHERE owner=? AND (relpath=? OR relpath LIKE ?)", (owner, old_rel, old_rel + "/%")).fetchall() |
| 12317 | for row in rows: |
| 12318 | suffix = row["relpath"][len(old_rel):] |
| 12319 | conn.execute(f"UPDATE {table} SET relpath=? WHERE id=?", (new_rel + suffix, row["id"])) |
| 12320 | conn.commit(); conn.close() |
| 12321 | |
| 12322 | |
| 12323 | def _parse_date_start(value: str) -> Optional[float]: |
nothing calls this directly
no test coverage detected