mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
linted routes/album.js
This commit is contained in:
parent
db2897fbe6
commit
413722ce68
@ -7,8 +7,9 @@ const db = require('knex')(config.database)
|
|||||||
|
|
||||||
routes.get('/a/:identifier', async (req, res, next) => {
|
routes.get('/a/:identifier', async (req, res, next) => {
|
||||||
const identifier = req.params.identifier
|
const identifier = req.params.identifier
|
||||||
if (identifier === undefined)
|
if (identifier === undefined) {
|
||||||
res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
||||||
|
}
|
||||||
|
|
||||||
const album = await db.table('albums')
|
const album = await db.table('albums')
|
||||||
.where({
|
.where({
|
||||||
@ -18,8 +19,9 @@ routes.get('/a/:identifier', async (req, res, next) => {
|
|||||||
.select('id', 'name', 'identifier', 'editedAt', 'download', 'public', 'description')
|
.select('id', 'name', 'identifier', 'editedAt', 'download', 'public', 'description')
|
||||||
.first()
|
.first()
|
||||||
|
|
||||||
if (!album || album.public === 0)
|
if (!album || album.public === 0) {
|
||||||
return res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
return res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
||||||
|
}
|
||||||
|
|
||||||
const nojs = req.query.nojs !== undefined
|
const nojs = req.query.nojs !== undefined
|
||||||
|
|
||||||
@ -28,21 +30,23 @@ routes.get('/a/:identifier', async (req, res, next) => {
|
|||||||
// Cache ID - we initialize a separate cache for No-JS version
|
// Cache ID - we initialize a separate cache for No-JS version
|
||||||
cacheid = nojs ? `${album.id}-nojs` : album.id
|
cacheid = nojs ? `${album.id}-nojs` : album.id
|
||||||
|
|
||||||
if (!utils.albumsCache[cacheid])
|
if (!utils.albumsCache[cacheid]) {
|
||||||
utils.albumsCache[cacheid] = {
|
utils.albumsCache[cacheid] = {
|
||||||
cache: null,
|
cache: null,
|
||||||
generating: false
|
generating: false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating)
|
if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating) {
|
||||||
return res.render('album-notice', {
|
return res.render('album-notice', {
|
||||||
config,
|
config,
|
||||||
versions: utils.versionStrings,
|
versions: utils.versionStrings,
|
||||||
album,
|
album,
|
||||||
notice: 'This album\'s public page is still being generated. Please try again later.'
|
notice: 'This album\'s public page is still being generated. Please try again later.'
|
||||||
})
|
})
|
||||||
else if (utils.albumsCache[cacheid].cache)
|
} else if (utils.albumsCache[cacheid].cache) {
|
||||||
return res.send(utils.albumsCache[cacheid].cache)
|
return res.send(utils.albumsCache[cacheid].cache)
|
||||||
|
}
|
||||||
|
|
||||||
utils.albumsCache[cacheid].generating = true
|
utils.albumsCache[cacheid].generating = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user