From c30bf31c55b5bcbd7baa1afb124cdcff65c1174c Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Fri, 11 Oct 2024 18:37:57 -0400 Subject: [PATCH] dev: make puter.fs cache togglable --- src/puter-js/src/modules/FileSystem/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/puter-js/src/modules/FileSystem/index.js b/src/puter-js/src/modules/FileSystem/index.js index 8078cc70..df4dcc4d 100644 --- a/src/puter-js/src/modules/FileSystem/index.js +++ b/src/puter-js/src/modules/FileSystem/index.js @@ -77,10 +77,18 @@ export class PuterJSFileSystemModule extends AdvancedBase { }); // Construct the decorator chain for the client-side filesystem. - let fs = new PuterAPIFilesystem({ api_info }).as(TFilesystem); - fs = new CachedFilesystem({ delegate: fs }).as(TFilesystem); - fs = new ProxyFilesystem({ delegate: fs }).as(TFilesystem); - this.filesystem = fs; + this.fs_nocache_ = new PuterAPIFilesystem({ api_info }).as(TFilesystem); + this.fs_cache_ = new CachedFilesystem({ delegate: this.fs_nocache_ }).as(TFilesystem); + // this.filesystem = this.fs_nocache; + this.fs_proxy_ = new ProxyFilesystem({ delegate: this.fs_nocache_ }); + this.filesystem = this.fs_proxy_.as(TFilesystem); + } + + cache_on () { + this.fs_proxy_.delegate = this.fs_cache_; + } + cache_off () { + this.fs_proxy_.delegate = this.fs_nocache_; }