Moved incrementation of total_files_size to if's file branch. So it won't add size of directories (4KiB each).
This commit is contained in:
parent
bd9964d300
commit
37511381ec
5
files.js
5
files.js
@ -54,7 +54,6 @@ async function getDirectoryList(dir_path, base_url) {
|
||||
for await (const dirent of d) {
|
||||
const stat = fs.lstatSync(path.join(dir_path, dirent.name));
|
||||
const [s, u] = convertSize(stat.size);
|
||||
total_files_size += stat.size;
|
||||
if (stat.isDirectory())
|
||||
dirs.push({
|
||||
name: dirent.name,
|
||||
@ -62,7 +61,8 @@ async function getDirectoryList(dir_path, base_url) {
|
||||
datetime: util.datetime(stat.mtime, util.formats.file_date),
|
||||
size: "DIR",
|
||||
size_unit: '' });
|
||||
else
|
||||
else {
|
||||
total_files_size += stat.size;
|
||||
files.push({
|
||||
name: dirent.name,
|
||||
link: `${base_url}${encodeURIComponent(dirent.name)}`,
|
||||
@ -70,6 +70,7 @@ async function getDirectoryList(dir_path, base_url) {
|
||||
size: +s,
|
||||
size_unit: u });
|
||||
}
|
||||
}
|
||||
|
||||
const sort_by_name = (a, b) => {
|
||||
if (a.name > b.name)
|
||||
|
Loading…
Reference in New Issue
Block a user