From 661f13fc9276cf18a2896cdca673675867a13744 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Sun, 12 Oct 2025 19:50:48 -0700 Subject: [PATCH] improve caching mechanism by deleting specific caches on item addition in FileSystem module (#1745) --- src/puter-js/src/modules/FileSystem/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/puter-js/src/modules/FileSystem/index.js b/src/puter-js/src/modules/FileSystem/index.js index f2ee6daf3..6dde45221 100644 --- a/src/puter-js/src/modules/FileSystem/index.js +++ b/src/puter-js/src/modules/FileSystem/index.js @@ -134,8 +134,12 @@ export class PuterJSFileSystemModule extends AdvancedBase { }); this.socket.on('item.added', (item) => { - puter._cache.flushall(); - console.log('Flushed cache for item.added'); + // remove readdir cache for parent + puter._cache.del('readdir:' + path.dirname(item.path)); + console.log('deleted cache for readdir:' + path.dirname(item.path)); + // remove item cache for parent directory + puter._cache.del('item:' + path.dirname(item.path)); + console.log('deleted cache for item:' + path.dirname(item.path)); }); this.socket.on('item.updated', (item) => {