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) => {
|
fs.readdirSync(curr).forEach((item) => {
|
||||||
if (item[0] !== '.') {
|
if (item[0] !== '.') {
|
||||||
let res = { name: item }
|
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.size = Math.round(fileSizeInBytes / 1000000)
|
||||||
|
|
||||||
res.path = relPath
|
res.path = relPath
|
||||||
if (res.path[res.path.length - 1] !== '/') { res.path += '/' }
|
if (res.path[res.path.length - 1] !== '/') { res.path += '/' }
|
||||||
res.path += item
|
res.path += item
|
||||||
|
|
||||||
res.mtime = stats['mtime'].toLocaleString()
|
res.mtime = stat['mtime'].toLocaleString()
|
||||||
|
res.isDir = stat.isDirectory()
|
||||||
|
|
||||||
f.push(res)
|
f.push(res)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,17 @@
|
||||||
<%=folders[i].mtime %>
|
<%=folders[i].mtime %>
|
||||||
</td>
|
</td>
|
||||||
<td style='width:10%;'>
|
<td style='width:10%;'>
|
||||||
<%= folders[i].size === 0 ? "Dir" : folders[i].size + 'MB' %>
|
<%
|
||||||
|
if (folders[i].isDir) {
|
||||||
|
%> <%= "DIR" %> <%
|
||||||
|
} else {
|
||||||
|
if (folders[i].size === 0) {
|
||||||
|
%> <%= "~0 MB" %> <%
|
||||||
|
} else {
|
||||||
|
%> <%= folders[i].size + ' MB' %> <%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue