aboutsummaryrefslogtreecommitdiff
path: root/modules/core/virtual-fs.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-05-26 06:00:26 +0200
committerAgando <roduccomm@gmail.com>2026-05-26 06:00:26 +0200
commitf4d934d341056142da1212c845eeeb170fd452c2 (patch)
tree55dd11c70d1342857537f4b0aeee6ea63d21545e /modules/core/virtual-fs.js
parent4baa484b84c5184286cac2743575251454a5ee2b (diff)
auto: 2026-05-26_06:00 changes
Diffstat (limited to 'modules/core/virtual-fs.js')
-rw-r--r--modules/core/virtual-fs.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/modules/core/virtual-fs.js b/modules/core/virtual-fs.js
index a505699..68d02bf 100644
--- a/modules/core/virtual-fs.js
+++ b/modules/core/virtual-fs.js
@@ -8,6 +8,12 @@ class VirtualFileSystem {
try {
const saved = localStorage.getItem('webx11_filesystem');
if (saved) {
+ // Safety: refuse to load if data is excessively large (>512KB raw)
+ if (saved.length > 524288) {
+ console.warn('FS data too large (' + (saved.length/1024).toFixed(0) + 'KB), skipping load');
+ localStorage.removeItem('webx11_filesystem');
+ return;
+ }
const data = JSON.parse(saved);
this.root = data.root || this.root;
this.currentPath = data.currentPath || [];
@@ -15,11 +21,16 @@ class VirtualFileSystem {
} catch (e) { console.error('FS load error:', e); }
}
saveToStorage() {
- try {
- localStorage.setItem('webx11_filesystem', JSON.stringify({
- root: this.root, currentPath: this.currentPath
- }));
- } catch (e) { console.error('FS save error:', e); }
+ if (this._storageSavePending) return;
+ this._storageSavePending = true;
+ setTimeout(() => {
+ this._storageSavePending = false;
+ try {
+ localStorage.setItem('webx11_filesystem', JSON.stringify({
+ root: this.root, currentPath: this.currentPath
+ }));
+ } catch (e) { console.error('FS save error:', e); }
+ }, 2000);
}
getCurrentDir() {
let dir = this.root;