mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Stuff module file/dir type/size fix
This commit is contained in:
parent
62a0e3fbc9
commit
5d822d3b6a
2 changed files with 15 additions and 4 deletions
|
@ -155,16 +155,17 @@ app.get('/*', function (req, res) {
|
|||
fs.readdirSync(curr).forEach((item) => {
|
||||
if (item[0] !== '.') {
|
||||
let res = { name: item }
|
||||
let stats = fs.statSync(curr + '/' + item)
|
||||
let stat = fs.statSync(curr + '/' + item)
|
||||
|
||||
let fileSizeInBytes = stats['size']
|
||||
let fileSizeInBytes = stat['size']
|
||||
res.size = Math.round(fileSizeInBytes / 1000000)
|
||||
|
||||
res.path = relPath
|
||||
if (res.path[res.path.length - 1] !== '/') { res.path += '/' }
|
||||
res.path += item
|
||||
|
||||
res.mtime = stats['mtime'].toLocaleString()
|
||||
res.mtime = stat['mtime'].toLocaleString()
|
||||
res.isDir = stat.isDirectory()
|
||||
|
||||
f.push(res)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue