Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(storage): a pass on a database this installation does not recognise only reports

Maurice13332cf06b90
diff --git a/server/src/nest/storage/storage-reclaim.service.ts b/server/src/nest/storage/storage-reclaim.service.ts
index ac3796df6..53a96e0e0 100644
--- a/server/src/nest/storage/storage-reclaim.service.ts
+++ b/server/src/nest/storage/storage-reclaim.service.ts
@@ -258,7 +258,12 @@ export class StorageReclaimService implements OnModuleInit {
private async pass(reportOnly: boolean, now: Date): Promise<StorageReclaimReport> {
const wallStart = Date.now();
const installId = this.install.installId();
- const deleting = !reportOnly && installId !== null && (await readReclaimDeleteEnabled(this.appSettings, installId));
+ // A database this installation does not recognise (a restore whose reset did not run yet) only reports.
+ const deleting =
+ !reportOnly &&
+ installId !== null &&
+ (await this.install.databaseIsThis(installId)) &&
+ (await readReclaimDeleteEnabled(this.appSettings, installId));
const ctx: PassContext = {
now: now.getTime(),
installId,
diff --git a/server/tests/unit/nest/storage/storage-reclaim.service.test.ts b/server/tests/unit/nest/storage/storage-reclaim.service.test.ts
index 03bd24653..38e5ac246 100644
--- a/server/tests/unit/nest/storage/storage-reclaim.service.test.ts
+++ b/server/tests/unit/nest/storage/storage-reclaim.service.test.ts
@@ -10,7 +10,7 @@
* an owner marker of another install keeps its hands off; a restore, or a
* database naming another install, resets the switch, the marks, the queue
* and the reports but keeps this install's id, and so does a restore's reset
- * file whatever id the database names. RCLS-001 to RCLS-045.
+ * file whatever id the database names. RCLS-001 to RCLS-046.
*/
import { AppSettings } from '../../../../src/db/entities/AppSettings.entity';
import { AuditLog } from '../../../../src/db/entities/AuditLog.entity';
@@ -890,6 +890,20 @@ describe('StorageReclaimService: a pass that stops, and a restore', () => {
expect((await reclaim.state()).deleteEnabled).toBe(false);
});
+ it('RCLS-046: while a restore's reset is still pending, the nightly pass only reports, whatever the switch says', async () => {
+ const sentinel = path.join(dataRoot, 'reclaim-reset');
+ await markedWeekOld(['orphan.jpg']);
+ fs.writeFileSync(sentinel, 'pending');
+ try {
+ const report = await reclaim.run({ now: WEEK_LATER });
+ expect(report.mode).toBe('report');
+ expect(report.categories.covers.deleted.objects).toBe(0);
+ expect(fs.existsSync(objectPath('covers', 'orphan.jpg'))).toBe(true);
+ } finally {
+ fs.rmSync(sentinel, { force: true });
+ }
+ });
+
it('RCLS-045: a reset file that cannot be removed is reset again on the next start, and the database is not this', async () => {
const install = t.get(StorageInstallService);
const sentinel = path.join(dataRoot, 'reclaim-reset');