mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
fix(storage): a pass on a database this installation does not recognise only reports
While a restore's reset is still pending, or the database names another installation, the nightly pass judges and reports but deletes nothing, whatever the restored switch says.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user