aboutsummaryrefslogtreecommitdiff
path: root/modules/core/core-bundle.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-10-23 15:28:57 +0200
committerAgando <roduccomm@gmail.com>2026-10-23 15:28:57 +0200
commit3cfb5ededbf482732b2337d82b5e05f96fc898de (patch)
tree78e601bb30d9fb491d4800b974be819ba0a4b15e /modules/core/core-bundle.js
parent09a9649d93c509ce563dd958e32f44a43a17a7f1 (diff)
fix(newos4): define VirtualFS.emptyTrash() — empty-trash threw since 2026-10-18
Report RPT-20261018-164646-89352963 ("this.fs.emptyTrash is not a function") was filed by the auto-filer and never fixed: terminal.js:1777 called a method VirtualFS never defined, so 'empty-trash --confirm' threw instead of emptying. Added emptyTrash() returning true only when it removed something. Verified live on v4.6.54: put -> rm -> empty-trash --confirm => 'Trash emptied.'; second run => 'Trash is already empty.'; .trash entries 0.
Diffstat (limited to 'modules/core/core-bundle.js')
-rw-r--r--modules/core/core-bundle.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/core/core-bundle.js b/modules/core/core-bundle.js
index 331e090..212573d 100644
--- a/modules/core/core-bundle.js
+++ b/modules/core/core-bundle.js
@@ -632,6 +632,19 @@ class VirtualFileSystem {
}
return false;
}
+ // Reported 2026-10-18 ("this.fs.emptyTrash is not a function") and verified 2026-10-23:
+ // terminal.js:1777 called this method but nothing ever defined it, so `empty-trash --confirm`
+ // threw instead of emptying. Returns true only when something was actually removed.
+ emptyTrash() {
+ const trash = this.root.content && this.root.content['.trash'];
+ if (!trash || !trash.content) return false;
+ const names = Object.keys(trash.content);
+ if (!names.length) return false;
+ names.forEach(n => { delete trash.content[n]; });
+ this.saveToStorage();
+ this._emitChange('/.trash');
+ return true;
+ }
_pruneTrash(maxEntries = 50) {
// Bounded trash: deletions are moves-to-trash, so without a cap / .trash/ was an
// unbounded second accumulator. Names start with a millis timestamp → sort = oldest first.