mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
Updates
* If files have to be added to an album on upload, it will now wait until they have either been succesfully added to the album or errored. * File names in thumb view will now show their full URL on their tooltip.
This commit is contained in:
parent
b31f28ddcf
commit
7f10cccf70
@ -409,8 +409,28 @@ uploadsController.processFilesForDisplay = async (req, res, files, existingFiles
|
||||
files.push(efile)
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
let albumErrored = false
|
||||
await Promise.all(files.map(async file => {
|
||||
const ext = path.extname(file.name).toLowerCase()
|
||||
if ((config.uploads.generateThumbnails.image && utils.imageExtensions.includes(ext)) || (config.uploads.generateThumbnails.video && utils.videoExtensions.includes(ext))) {
|
||||
file.thumb = `${basedomain}/thumbs/${file.name.slice(0, -ext.length)}.png`
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
|
||||
if (file.albumid) {
|
||||
return db.table('albums')
|
||||
.where('id', file.albumid)
|
||||
.update('editedAt', file.timestamp)
|
||||
.catch(error => {
|
||||
albumErrored = true
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
}))
|
||||
|
||||
return res.json({
|
||||
success: !albumErrored,
|
||||
description: albumErrored ? 'Successfully uploaded files but unable to add to album.' : undefined,
|
||||
files: files.map(file => {
|
||||
return {
|
||||
name: file.name,
|
||||
@ -419,22 +439,6 @@ uploadsController.processFilesForDisplay = async (req, res, files, existingFiles
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
for (let file of files) {
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if ((config.uploads.generateThumbnails.image && utils.imageExtensions.includes(ext)) || (config.uploads.generateThumbnails.video && utils.videoExtensions.includes(ext))) {
|
||||
file.thumb = `${basedomain}/thumbs/${file.name.slice(0, -ext.length)}.png`
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
|
||||
if (file.albumid) {
|
||||
db.table('albums')
|
||||
.where('id', file.albumid)
|
||||
.update('editedAt', file.timestamp)
|
||||
.then(() => {})
|
||||
.catch(error => { console.log(error); res.json({ success: false, description: 'Error updating album.' }) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uploadsController.delete = async (req, res) => {
|
||||
|
@ -56,9 +56,11 @@ utilsController.generateThumbs = (file, basedomain) => {
|
||||
const isVideoExt = utilsController.videoExtensions.includes(ext)
|
||||
const isImageExt = utilsController.imageExtensions.includes(ext)
|
||||
|
||||
if (!isVideoExt && !isImageExt) { return }
|
||||
if (isVideoExt && config.uploads.generateThumbnails.video !== true) { return }
|
||||
if (isImageExt && config.uploads.generateThumbnails.image !== true) { return }
|
||||
if ((!isVideoExt && !isImageExt) ||
|
||||
(isVideoExt && config.uploads.generateThumbnails.video !== true) ||
|
||||
(isImageExt && config.uploads.generateThumbnails.image !== true)) {
|
||||
return
|
||||
}
|
||||
|
||||
let thumbname = path.join(__dirname, '..', config.uploads.folder, 'thumbs', file.name.slice(0, -ext.length) + '.png')
|
||||
fs.access(thumbname, error => {
|
||||
|
@ -35,7 +35,7 @@ safe.use(bodyParser.json())
|
||||
const setHeaders = (res, path, stat) => {
|
||||
if (/\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|js|css|eot|svg|ttf|woff|woff2)$/.test(path)) {
|
||||
res.set('Access-Control-Allow-Origin', '*')
|
||||
res.set('Cache-Control', `public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800`) // max-age: 30 days
|
||||
res.set('Cache-Control', 'public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800') // max-age: 30 days
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<script type="text/javascript" src="libs/sweetalert/sweetalert.min.js?v=vvtL7Y3cjD"></script>
|
||||
<script type="text/javascript" src="libs/axios/axios.min.js?v=vvtL7Y3cjD"></script>
|
||||
<script type="text/javascript" src="libs/clipboard.js/clipboard.min.js?v=vvtL7Y3cjD"></script>
|
||||
<script type="text/javascript" src="js/dashboard.js?v=U4oQBt8aIF"></script>
|
||||
<script type="text/javascript" src="js/dashboard.js?v=pH3317eTYZ"></script>
|
||||
|
||||
<!-- Open Graph tags -->
|
||||
<meta property="og:type" content="website" />
|
||||
|
@ -218,7 +218,7 @@ panel.getUploads = (album, page, element) => {
|
||||
</a>
|
||||
</div>
|
||||
<div class="details">
|
||||
<p><span class="name">${file.name}</span></p>
|
||||
<p><span class="name" title="${file.file}">${file.name}</span></p>
|
||||
<p>${displayAlbumOrUser ? `<span>${displayAlbumOrUser}</span> – ` : ''}${file.size}</div>
|
||||
`
|
||||
table.appendChild(div)
|
||||
|
Loading…
Reference in New Issue
Block a user