fileman 0.02: Improve handling of large amounts of files (fix #579)

pull/608/head
Gordon Williams 2020-12-08 16:41:24 +00:00
parent 30f66a8775
commit 6a63a6ea47
3 changed files with 10 additions and 6 deletions

View File

@ -2293,7 +2293,7 @@
"name": "File manager", "name": "File manager",
"shortName":"FileManager", "shortName":"FileManager",
"icon": "icons8-filing-cabinet-48.png", "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", "description": "Simple file manager, allows user to examine watch storage and display, load or delete individual files",
"tags": "tools", "tags": "tools",
"readme": "README.md", "readme": "README.md",

View File

@ -1 +1,2 @@
0.01: New app! 0.01: New app!
0.02: Improve handling of large amounts of files (fix #579)

View File

@ -10,12 +10,12 @@ function delete_file(fn) {
E.showPrompt("Delete\n"+fn+"?", {buttons: {"No":false, "Yes":true}}).then(function(v) { E.showPrompt("Delete\n"+fn+"?", {buttons: {"No":false, "Yes":true}}).then(function(v) {
if (v) { if (v) {
if (fn.charCodeAt(fn.length-1)==1) { 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(); fh.erase();
} }
else STOR.erase(fn); 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) { function get_length(fn) {
@ -90,10 +90,13 @@ function drawMenu() {
} }
function get_pruned_file_list() { 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.sort();
fl = fl.concat(STOR.list(/^\./)); fl = fl.concat(STOR.list(/^\./).filter(sffilter).sort());
fl = fl.filter(f => (f.charCodeAt(f.length-1)>31 || f.charCodeAt(f.length-1)<2));
return fl; return fl;
} }