mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-05 19:40:09 +00:00
feat: send more data in upload API response
This commit is contained in:
parent
0b46f43bfa
commit
e64cfa89cf
@ -1030,7 +1030,8 @@ self.storeFilesToDb = async (req, res, filesData) => {
|
|||||||
const stored = []
|
const stored = []
|
||||||
const albumids = []
|
const albumids = []
|
||||||
|
|
||||||
await Promise.all(filesData.map(async file => {
|
// for-loop to prioritize sequential ordering over multiple async sub-tasks
|
||||||
|
for (const file of filesData) {
|
||||||
if (enableHashing) {
|
if (enableHashing) {
|
||||||
// Check if the file exists by checking its hash and size
|
// Check if the file exists by checking its hash and size
|
||||||
const dbFile = await utils.db.table('files')
|
const dbFile = await utils.db.table('files')
|
||||||
@ -1045,8 +1046,6 @@ self.storeFilesToDb = async (req, res, filesData) => {
|
|||||||
hash: file.hash,
|
hash: file.hash,
|
||||||
size: String(file.size)
|
size: String(file.size)
|
||||||
})
|
})
|
||||||
// Select expirydate to display expiration date of existing files as well
|
|
||||||
.select('name', 'expirydate')
|
|
||||||
.first()
|
.first()
|
||||||
|
|
||||||
if (dbFile) {
|
if (dbFile) {
|
||||||
@ -1064,7 +1063,7 @@ self.storeFilesToDb = async (req, res, filesData) => {
|
|||||||
file: dbFile,
|
file: dbFile,
|
||||||
repeated: true
|
repeated: true
|
||||||
})
|
})
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1098,7 +1097,7 @@ self.storeFilesToDb = async (req, res, filesData) => {
|
|||||||
if (utils.mayGenerateThumb(file.extname)) {
|
if (utils.mayGenerateThumb(file.extname)) {
|
||||||
utils.generateThumbs(file.filename, file.extname, true).catch(logger.error)
|
utils.generateThumbs(file.filename, file.extname, true).catch(logger.error)
|
||||||
}
|
}
|
||||||
}))
|
}
|
||||||
|
|
||||||
const fresh = stored.filter(entry => !entry.repeated)
|
const fresh = stored.filter(entry => !entry.repeated)
|
||||||
if (fresh.length) {
|
if (fresh.length) {
|
||||||
@ -1147,7 +1146,10 @@ self.sendUploadResponse = async (req, res, stored) => {
|
|||||||
files: stored.map(entry => {
|
files: stored.map(entry => {
|
||||||
const map = {
|
const map = {
|
||||||
name: entry.file.name,
|
name: entry.file.name,
|
||||||
url: `${utils.conf.domain ? `${utils.conf.domain}/` : ''}${entry.file.name}`
|
original: entry.file.original,
|
||||||
|
url: `${utils.conf.domain ? `${utils.conf.domain}/` : ''}${entry.file.name}`,
|
||||||
|
hash: entry.file.hash,
|
||||||
|
size: Number(entry.file.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a temporary upload, add expiry date
|
// If a temporary upload, add expiry date
|
||||||
|
Loading…
Reference in New Issue
Block a user