File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
src/puter-js/src/modules/FileSystem Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -153,9 +153,22 @@ export class PuterJSFileSystemModule extends AdvancedBase {
153153 } ) ;
154154
155155 this . socket . on ( 'item.added' , ( item ) => {
156- // check original_client_socket_id and if it matches this.socket.id, don't invalidate cache
157- puter . _cache . flushall ( ) ;
158- console . log ( 'Flushed cache for item.added' ) ;
156+ // delete item from cache
157+ puter . _cache . del ( 'item:' + item . path ) ;
158+ // delete readdir from cache
159+ puter . _cache . del ( 'readdir:' + item . path ) ;
160+ // delete descendant items from cache
161+ const descendant_items = puter . _cache . keys ( 'item:' + item . path + '/*' ) ;
162+ for ( const descendant of descendant_items ) {
163+ puter . _cache . del ( descendant ) ;
164+ }
165+ // delete descendant readdirs from cache
166+ const descendant_readdirs = puter . _cache . keys ( 'readdir:' + item . path + '/*' ) ;
167+ for ( const descendant of descendant_readdirs ) {
168+ puter . _cache . del ( descendant ) ;
169+ }
170+ // delete parent readdir from cache
171+ puter . _cache . del ( 'readdir:' + path . dirname ( item . path ) ) ;
159172 } ) ;
160173
161174 this . socket . on ( 'item.updated' , ( item ) => {
You can’t perform that action at this time.
0 commit comments