forked from svrjs/svrjs
Fix "NaN" file sizes in directory listings
This commit is contained in:
parent
e293c08592
commit
1444660d19
2 changed files with 2 additions and 2 deletions
|
@ -773,7 +773,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
.replace(/>/g, ">")}</a></td><td>${
|
.replace(/>/g, ">")}</a></td><td>${
|
||||||
estats.isDirectory()
|
estats.isDirectory()
|
||||||
? "-"
|
? "-"
|
||||||
: sizify(estats.size.toString())
|
: sizify(estats.size)
|
||||||
}</td><td>${estats.mtime.toDateString()}</td></tr>\r\n`;
|
}</td><td>${estats.mtime.toDateString()}</td></tr>\r\n`;
|
||||||
|
|
||||||
// Determine the file type and set the appropriate image and alt text
|
// Determine the file type and set the appropriate image and alt text
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function sizify(bytes, addI) {
|
function sizify(bytes, addI) {
|
||||||
if (bytes === 0) return "0";
|
if (bytes == 0) return "0";
|
||||||
if (bytes < 0) bytes = -bytes;
|
if (bytes < 0) bytes = -bytes;
|
||||||
|
|
||||||
const prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
|
const prefixes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
|
||||||
|
|
Reference in a new issue