Added total size to album public pages.
This commit is contained in:
Bobby Wibowo 2018-12-13 20:31:24 +07:00
parent 7d55b43ef2
commit 7665836ef4
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
4 changed files with 13 additions and 6 deletions

View File

@ -238,7 +238,12 @@ authController.listUsers = async (req, res, next) => {
for (const upload of uploads) {
// This is the fastest method that I can think of
if (maps[upload.userid] === undefined) { maps[upload.userid] = { count: 0, size: 0 } }
if (maps[upload.userid] === undefined) {
maps[upload.userid] = {
count: 0,
size: 0
}
}
maps[upload.userid].count++
maps[upload.userid].size += parseInt(upload.size)
}

View File

@ -261,9 +261,8 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => {
return erred('File too large.')
}
const fetchFile = await fetch(url, {
size // limit max response body size with content-length
})
// limit max response body size with content-length
const fetchFile = await fetch(url, { size })
if (fetchFile.status !== 200) {
return erred(`${fetchHead.status} ${fetchHead.statusText}`)
}

View File

@ -39,8 +39,10 @@ routes.get('/a/:identifier', async (req, res, next) => {
let thumb = ''
const basedomain = config.domain
let totalSize = 0
for (const file of files) {
file.file = `${basedomain}/${file.name}`
totalSize += parseInt(file.size)
file.extname = path.extname(file.name).toLowerCase()
if (utils.mayGenerateThumb(file.extname)) {
@ -65,7 +67,8 @@ routes.get('/a/:identifier', async (req, res, next) => {
generateZips: config.uploads.generateZips,
downloadLink: album.download === 0 ? null : `../api/album/zip/${album.identifier}?v=${album.editedAt}`,
editedAt: album.editedAt,
url: `${homeDomain}/a/${album.identifier}`
url: `${homeDomain}/a/${album.identifier}`,
totalSize
})
})

View File

@ -42,7 +42,7 @@
</div>
<div class="level-item">
<h1 id="count" class="subtitle">
{{ count }} files
{{ count }} files (<span class="file-size">{{ totalSize }}</span>)
</h1>
</div>
</div>