mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-25 17:03:52 +00:00
Picked up the remaining items from the multi-agent review:
- Hoist Operation / ServerOperation imports in sync.routes.ts so the
upload path no longer needs `as unknown as import('./sync.types').*`
double casts. The Set + filter pattern for accepted ops becomes an
index-zip loop, dropping two iterations + the Set allocation.
- Pull APPROX_BYTES_PER_OP out of two inline locals in sync.service.ts
into sync.const.ts so the constant is a single source of truth and
the trade-off (over-estimate vs observed median op size) is documented
in one place.
- Log when computeOpsStorageBytes silently skips an op whose payload
fails JSON.stringify (BigInt, circular refs). Counter still
under-counts but the cause is visible in logs.
- Update storage-quota docstrings to reflect that calculateStorageUsage /
updateStorageUsage are now legitimately called from the
freeStorageForUpload reconcile path (rare cleanup events), not only
offline.
Tests:
- cleanup.spec.ts: assert updateStorageUsage is NOT called after
deleteOldSyncedOpsForAllUsers (the per-user SUM loop was the DoS).
- storage-quota-cleanup.spec.ts: drop the assertion that
deleteOldestRestorePointAndOps issues a pg_column_size query (it does
not anymore); add a $executeRaw mock that mutates testUsers so the
iterative-cleanup test exercises the real decrement path; tune
starting storage to within a few KB of quota so cleanup's
approximate decrement can detect progress within a few iterations.
- storage-quota.service.spec.ts: add the $executeRaw prisma mock and
unit tests for incrementStorageUsage / decrementStorageUsage
(positive path, Math.floor of non-integer deltas, no-op on
NaN/Infinity/zero/negative, clamped UPDATE for decrement).
|
||
|---|---|---|
| .. | ||
| integration | ||
| api.routes.spec.ts | ||
| auth-flows.spec.ts | ||
| cleanup.spec.ts | ||
| config.spec.ts | ||
| conflict-detection.spec.ts | ||
| decompress-body.spec.ts | ||
| device.service.spec.ts | ||
| duplicate-operation-precheck.spec.ts | ||
| email.spec.ts | ||
| gap-detection.spec.ts | ||
| magic-link-registration.spec.ts | ||
| middleware.spec.ts | ||
| migration-sql.spec.ts | ||
| operation-download.service.spec.ts | ||
| passkey.spec.ts | ||
| password-reset-api.spec.ts | ||
| password-reset.spec.ts | ||
| rate-limit.service.spec.ts | ||
| registration-api.spec.ts | ||
| replace-token-expiry.spec.ts | ||
| request-deduplication.service.spec.ts | ||
| retention-config.spec.ts | ||
| security-fixes.spec.ts | ||
| server-security.spec.ts | ||
| setup.ts | ||
| snapshot-skip-optimization.spec.ts | ||
| snapshot.service.spec.ts | ||
| storage-quota-cleanup.spec.ts | ||
| storage-quota.service.spec.ts | ||
| sync-compressed-body.routes.spec.ts | ||
| sync-fixes.spec.ts | ||
| sync-operations.spec.ts | ||
| sync-types.spec.ts | ||
| sync.routes.spec.ts | ||
| sync.service.spec.ts | ||
| sync.service.test-state.ts | ||
| time-tracking-operations.spec.ts | ||
| validation.service.spec.ts | ||
| websocket-connection.service.spec.ts | ||
| websocket.routes.spec.ts | ||