Skip to content

Commit

Permalink
fileman 0.02: Improve handling of large amounts of files (fix espruin…
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Dec 8, 2020
1 parent 30f66a8 commit 6a63a6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@
"name": "File manager",
"shortName":"FileManager",
"icon": "icons8-filing-cabinet-48.png",
"version":"0.01",
"version":"0.02",
"description": "Simple file manager, allows user to examine watch storage and display, load or delete individual files",
"tags": "tools",
"readme": "README.md",
Expand Down
1 change: 1 addition & 0 deletions apps/fileman/ChangeLog
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.01: New app!
0.02: Improve handling of large amounts of files (fix #579)
13 changes: 8 additions & 5 deletions apps/fileman/fileman.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ function delete_file(fn) {
E.showPrompt("Delete\n"+fn+"?", {buttons: {"No":false, "Yes":true}}).then(function(v) {
if (v) {
if (fn.charCodeAt(fn.length-1)==1) {
var fh = STOR.open(fn.substr(0, fn.length-1), "w");
var fh = STOR.open(fn.substr(0, fn.length-1), "r");
fh.erase();
}
else STOR.erase(fn);
}
}).then(function() { files=get_pruned_file_list(); }).then(drawMenu);
}).then(function() { filed=[];files=get_pruned_file_list(); }).then(drawMenu);
}

function get_length(fn) {
Expand Down Expand Up @@ -90,10 +90,13 @@ function drawMenu() {
}

function get_pruned_file_list() {
var fl = STOR.list(/^[^\.]/);
// get storagefile list
var sf = STOR.list(/\1$/).map(s=>s.slice(0,-1));
var sffilter = f=>!sf.includes(f.slice(0,-1)) || f.endsWith("\1");
// get files - put '.' last
var fl = STOR.list(/^[^\.]/).filter(sffilter);
fl.sort();
fl = fl.concat(STOR.list(/^\./));
fl = fl.filter(f => (f.charCodeAt(f.length-1)>31 || f.charCodeAt(f.length-1)<2));
fl = fl.concat(STOR.list(/^\./).filter(sffilter).sort());
return fl;
}

Expand Down

0 comments on commit 6a63a6e

Please sign in to comment.