Thorrent Updater Notes
======================

Client side
-----------
Open Settings -> About.

Controls:
- Set URL: paste your update server URL or exact endpoint.
- Check Updates: fetches api/latest.php, compares versions, and shows a release modal if newer.
- Open Site: opens the configured URL in the browser.
- Update Log: shows endpoint, current/remote versions, ZIP path, checksum information, backup path, installer status, and recent logs.
- Check for updates on startup: optional automatic check after launch.

Expected endpoint JSON:
{
  "ok": true,
  "app": "Thorrent",
  "version": "v0.9.99.33",
  "filename": "Thorrent_v0.9.99.33.zip",
  "size_bytes": 123456,
  "sha256": "...",
  "changelog": "...",
  "published_at": "2026-06-22 17:00:00",
  "download_url": "https://example.com/thorrent-updates/download.php?id=..."
}

Install behavior
----------------
When you click Download in an update modal:
1. Thorrent downloads the ZIP to data/updates/downloads.
2. Thorrent verifies SHA256 if the server provides it.
3. Thorrent writes data/updates/last_download.json and data/updates/update_plan.json.
4. Thorrent shows a final Ready to Install confirmation.
5. Install Now starts tools/windows/apply_update.bat and closes Thorrent.
6. The updater creates a rollback backup in data/updates/backups.
7. The updater overlays the current app folder with the ZIP contents.
8. The updater preserves protected data/config and restarts Thorrent from the same folder.

Protected paths
---------------
The updater preserves:
- data/queue
- data/plugins
- data/resume
- data/updates
- config/settings.json
- config/sources.json
- config/qbit_plugin_lab.json
- config/imports

Diagnostics paths
-----------------
- data/updates/logs/update_diagnostics.log
- data/updates/logs/last_update.log
- data/updates/last_download.json
- data/updates/last_update.json
- data/updates/backups/

Notes
-----
This updater is intentionally conservative. It overlays files into the existing folder and does not delete old files that are absent from the new ZIP.
