bugfix meta-fuse

This commit is contained in:
Pierre
2026-01-17 19:59:15 +01:00
parent cefd0f73be
commit df0a1d6794
2 changed files with 94 additions and 0 deletions
@@ -150,6 +150,50 @@ export class VirtualFileSystem {
logger.info('VirtualFileSystem stopped');
}
/**
* Reset the VFS to empty state
* Called when meta-sort triggers a fresh scan
* The VFS will be rebuilt incrementally as files are processed via pub/sub
*
* IMPORTANT: This stops the periodic refresh timer to prevent repopulating
* from Redis (which still has old data). The VFS will only update via
* incremental pub/sub events until the next full refresh is triggered.
*/
reset(): void {
logger.info('Resetting VFS for fresh scan...');
// Stop periodic refresh to prevent repopulating from stale Redis data
if (this.refreshTimer) {
clearInterval(this.refreshTimer);
this.refreshTimer = null;
logger.info('Periodic refresh timer stopped - VFS will update via pub/sub only');
}
this.initRoot();
this.lastRefresh = null;
logger.info('VFS reset complete - awaiting new file updates from meta-sort');
}
/**
* Resume periodic refresh from Redis
* Called after a scan is complete to re-enable auto-refresh
*/
resumePeriodicRefresh(): void {
if (this.refreshTimer) {
logger.debug('Periodic refresh already running');
return;
}
logger.info('Resuming periodic refresh from Redis');
this.refreshTimer = setInterval(async () => {
try {
await this.refresh();
} catch (error) {
logger.error('Failed to refresh VFS:', error);
}
}, this.config.refreshInterval);
}
/**
* Refresh the VFS from Redis
* Uses template-based rules if configured, otherwise falls back to MetaDataToFolderStruct