Stuff module file/dir type/size fix

This commit is contained in:
MrFry 2019-11-18 17:56:58 +01:00
parent 62a0e3fbc9
commit 5d822d3b6a
2 changed files with 15 additions and 4 deletions

View file

@ -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)
} }

View file

@ -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>