mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: release QA hardening across processing, media, security, and CI gates (#649)
A release-readiness QA pass over the whole product. The commits split into defects a user would hit and gates that were reporting green while measuring nothing. ## Fixes that change behaviour Rate limiting was bypassable on every install: TRUST_PROXY defaulted to true, so request.ip came from a client-set header and a forged X-Forwarded-For got past the login limiter. The default is now a private-network trust list. A transient Postgres outage stranded in-flight jobs, leaving finished output on disk with no row pointing at it. A reconciler now resolves those rows and adopts the bytes rather than dropping the work. A Redis connection that moved to a new address wedged every read-blocked consumer, so completions stopped signalling while health still answered 200. Socket timeouts plus subscriber pings recover it. Installing more than one AI bundle left the shared venv multi-versioned and silently broke three tools. The installer now reconciles distributions to one version each. Converting an image to JXL at quality 1 through 4 returned a 500, because libjxl 0.7 rejects the distance those values compute. The quality is floored at what the encoder honours. A missing ffmpeg was also reported to the user as a corrupt upload; it now says the engine is unavailable. RAW uploads reached an unpatched LibRaw on arm64, so it is built from source at 0.22.2, and the release scan was split so it can fail on an unfixed critical instead of hiding it behind ignore-unfixed. ## Gates that could not fail Two mutation lanes ran zero mutants because Stryker crawled the gitignored docs build; coverage discarded its whole report on any failing test; the lint gate skipped root tests, scripts, and two workspaces; and several generated matrices counted a host missing ffmpeg as a passing tool. Each now measures what it claims. Full evidence and the outstanding release items are tracked locally and are not part of this branch.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
---
|
||||
description: "مخطط قاعدة بيانات PostgreSQL، والجداول، وعمليات الترحيل، وإجراءات النسخ الاحتياطي في SnapOtter."
|
||||
i18n_source_hash: 50d5d4f220cf
|
||||
i18n_provenance: human
|
||||
i18n_output_hash: fd2c87426e2d
|
||||
i18n_source_hash: a68264552836
|
||||
i18n_provenance: machine
|
||||
i18n_output_hash: 2ee3b1bee0e9
|
||||
i18n_hash_version: 2
|
||||
---
|
||||
|
||||
# قاعدة البيانات {#database}
|
||||
@@ -145,6 +146,17 @@ i18n_output_hash: fd2c87426e2d
|
||||
| `details` | jsonb | بيانات خاصة بالإجراء |
|
||||
| `createdAt` | timestamp | وقت الإجراء |
|
||||
|
||||
### user_preferences {#user-preferences}
|
||||
|
||||
حالة الواجهة لكل مستخدم، مفهرسة باسم التفضيل. تخزن الأدوات المثبّتة في الصفحة الرئيسية، وتُكتب عبر `PUT /api/v1/preferences`.
|
||||
|
||||
| العمود | النوع | ملاحظات |
|
||||
|---|---|---|
|
||||
| `userId` | text | مفتاح خارجي إلى users، مع حذف متتالٍ. جزء من المفتاح الأساسي مع `key` |
|
||||
| `key` | text | اسم التفضيل. جزء من المفتاح الأساسي مع `userId` |
|
||||
| `value` | jsonb | محتوى التفضيل |
|
||||
| `updatedAt` | timestamp | وقت آخر كتابة |
|
||||
|
||||
## عمليات الترحيل {#migrations}
|
||||
|
||||
يتولى Drizzle ترحيلات المخطط. تقع ملفات الترحيل في `apps/api/drizzle/`. أثناء التطوير:
|
||||
@@ -157,29 +169,37 @@ npx drizzle-kit migrate # apply pending migrations
|
||||
|
||||
في بيئة الإنتاج، تُطبَّق عمليات الترحيل المعلَّقة تلقائيًا عند بدء التشغيل.
|
||||
|
||||
## النسخ الاحتياطي والاستعادة {#backup-and-restore}
|
||||
## النسخ الاحتياطي واستعادة {#backup-and-restore}
|
||||
|
||||
تقع قاعدة البيانات العلائقية في وحدة تخزين `SnapOtter-pgdata` الخاصة بحاوية Postgres، وليس في وحدة تخزين `/data` الخاصة بالتطبيق.
|
||||
توجد قاعدة البيانات العلائقية في حجم `SnapOtter-pgdata` الخاص بحاوية Postgres، وليس في حجم `/data` الخاص بالتطبيق.
|
||||
|
||||
**الخيار 1: pg_dump (موصى به)**
|
||||
** النسخ الاحتياطي المنطقي مع التحقق من الصحة (مستحسن) **
|
||||
|
||||
```bash
|
||||
# Dump the database while the stack is running
|
||||
docker exec SnapOtter-postgres pg_dump -U snapotter snapotter > backup.sql
|
||||
# Dump into PostgreSQL's portable custom archive format
|
||||
docker exec SnapOtter-postgres \
|
||||
pg_dump --format=custom --no-owner -U snapotter snapotter > snapotter.dump
|
||||
test -s snapotter.dump
|
||||
docker exec -i SnapOtter-postgres pg_restore --list < snapotter.dump >/dev/null
|
||||
|
||||
# Restore into a fresh database
|
||||
cat backup.sql | docker exec -i SnapOtter-postgres psql -U snapotter snapotter
|
||||
# Restore into a fresh/disposable target first and fail on the first SQL error
|
||||
docker exec -i SnapOtter-postgres \
|
||||
pg_restore --exit-on-error --clean --if-exists --no-owner \
|
||||
-U snapotter -d snapotter < snapotter.dump
|
||||
```
|
||||
|
||||
**الخيار 2: لقطة وحدة التخزين**
|
||||
لا يحتوي تفريغ قاعدة البيانات على كائنات المكتبة المحفوظة في `/data/files` أو حالة BullMQ الدائمة في Redis. قم بعمل نسخة احتياطية من تلك العناصر واستعادتها باستخدام الإجراء المنسق في [الأمان والتقوية](/ar/guide/security#backup-and-recovery).
|
||||
|
||||
**لقطة من الحجم البارد**
|
||||
|
||||
```bash
|
||||
# Stop the stack, then snapshot the pgdata volume
|
||||
docker compose down
|
||||
docker run --rm -v SnapOtter-pgdata:/data -v $(pwd)/backup:/backup \
|
||||
alpine tar czf /backup/snapotter-pgdata.tar.gz -C /data .
|
||||
# Stop every service first, then use your storage platform to snapshot the
|
||||
# PostgreSQL, app-data, and Redis volumes as one crash-consistent set.
|
||||
docker compose -f docker/docker-compose.yml stop
|
||||
```
|
||||
|
||||
لا تقم بنسخ دليل بيانات PostgreSQL المباشر باستخدام `tar`. أنشئ أسماء وحدات التخزين البادئة حسب المشروع، لذا قم بحل معرفات وحدات التخزين المحملة من `docker inspect` أو منصة التخزين الخاصة بك بدلاً من افتراض التسمية الحرفية `SnapOtter-pgdata`.
|
||||
|
||||
### الترحيل من 1.x (SQLite) {#migrating-from-1-x-sqlite}
|
||||
|
||||
للترقية من SnapOtter 1.x دليل خاص بها: انظر [الترقية من 1.x إلى 2.0](./upgrading). باختصار، أعد استخدام وحدة تخزين `/data` الموجودة لديك، وسيكتشف الإصدار 2.0 تلقائيًا `/data/snapotter.db` ويستوردها عند التشغيل الأول (أو اضبط `SQLITE_MIGRATE_PATH` للإشارة إليها بشكل صريح). انسخ وحدة تخزين `/data` بأكملها احتياطيًا أولًا، وليس `snapotter.db` فقط: يستخدم الإصدار 1.x وضع SQLite WAL، لذا كثيرًا ما تترك الحاوية المتوقفة معظم بياناتها في `snapotter.db-wal` بجوار `snapotter.db` شبه الفارغ.
|
||||
|
||||
Reference in New Issue
Block a user