mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
The daily scan keeps one baseline per stored file and reports every baseline whose file is gone as a StorageBleed. Nothing ever removed a baseline, so every attachment purged by retention and every avatar deleted was reported missing on every run from then on - one finding folded 1,164 times. The baseline is now forgotten where WeKan deletes or moves a local file: - Attachments and Avatars onAfterRemove, for every version path. This is the retention purge's path: Meteor-Files unlinks the version paths itself after that hook, without going through the store strategy, so a fix in the strategy's unlink() alone would not have covered it; - the filesystem strategy's unlink() (moving a file to GridFS or cloud); - the filesystem strategy's rename(), for the old path. A file that vanishes any other way keeps its baseline and is still reported. The removal is fire-and-forget and can never break a delete. Baselines already orphaned before this fix stay reported until removed, as described in the issue. Thanks to Raymond-Voogt and xet7 ! Fixes #6898.
21 lines
874 B
JavaScript
21 lines
874 B
JavaScript
// #6898: forget the file-integrity baselines of files WeKan itself deletes or
|
|
// moves, so the daily scan does not report them as missing forever. See
|
|
// models/lib/fileIntegrityBaselineIds.cjs.
|
|
const { baselineIdsFor, versionPathsOf } = require('/models/lib/fileIntegrityBaselineIds.cjs');
|
|
|
|
export async function forgetIntegrityBaselines(paths) {
|
|
const ids = baselineIdsFor(paths);
|
|
if (ids.length === 0) return 0;
|
|
const FileIntegrity = require('/models/fileIntegrity').default;
|
|
return FileIntegrity.removeAsync({ _id: { $in: ids } });
|
|
}
|
|
|
|
// Fire-and-forget: a delete must never fail because its bookkeeping did.
|
|
export function forgetIntegrityBaselinesSoon(paths) {
|
|
forgetIntegrityBaselines(paths).catch(() => { /* bookkeeping only */ });
|
|
}
|
|
|
|
export function forgetIntegrityBaselinesOfFiles(fileObjs) {
|
|
forgetIntegrityBaselinesSoon(versionPathsOf(fileObjs));
|
|
}
|