1
0
Fork 0
forked from svrjs/svrjs

Optimize portions from directory listing function

This commit is contained in:
Dorian Niemiec 2024-04-24 13:03:53 +02:00
parent d789fea921
commit 3a4cefa67a

18
svr.js
View file

@ -3860,10 +3860,9 @@ if (!cluster.isPrimary) {
fs.stat((prefix + "/" + fileList[index]).replace(/\/+/g, "/"), function (err, stats) {
if (err) {
fs.lstat((prefix + "/" + fileList[index]).replace(/\/+/g, "/"), function (err, stats) {
if (err) {
pushArray.push({
name: fileList[index],
stats: null,
stats: err ? null : stats,
errored: true
});
if (index < fileList.length - 1) {
@ -3871,18 +3870,6 @@ if (!cluster.isPrimary) {
} else {
callback(pushArray);
}
} else {
pushArray.push({
name: fileList[index],
stats: stats,
errored: true
});
if (index < fileList.length - 1) {
getStatsForAllFilesI(fileList, callback, prefix, pushArray, index + 1);
} else {
callback(pushArray);
}
}
});
} else {
pushArray.push({
@ -3913,8 +3900,7 @@ if (!cluster.isPrimary) {
var estats = filelist[i].stats;
var ename = filelist[i].name;
var eext = ename.match(/\.([^.]+)$/);
if (eext) eext = eext[1];
else eext = "";
eext = eext ? eext[1] : "";
var emime = eext ? mime.contentType(eext) : false;
if (filelist[i].errored) {
directoryListingRows.push(