mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 00:46:22 +00:00
fix: size attribute of uploads with stripped tags
it'd previously always keep size attribute before the tags stripping
This commit is contained in:
parent
0eb4c243c3
commit
a49842a932
@ -527,6 +527,7 @@ self.actuallyUpload = async (req, res, data = {}) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip tags, then update their size attribute, if required
|
||||||
await self.stripTags(req, filesData)
|
await self.stripTags(req, filesData)
|
||||||
|
|
||||||
const stored = await self.storeFilesToDb(req, res, filesData)
|
const stored = await self.storeFilesToDb(req, res, filesData)
|
||||||
@ -862,6 +863,7 @@ self.actuallyFinishChunks = async (req, res, files) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip tags, then update their size attribute, if required
|
||||||
await self.stripTags(req, filesData)
|
await self.stripTags(req, filesData)
|
||||||
|
|
||||||
const stored = await self.storeFilesToDb(req, res, filesData)
|
const stored = await self.storeFilesToDb(req, res, filesData)
|
||||||
@ -971,9 +973,13 @@ self.stripTags = async (req, filesData) => {
|
|||||||
if (!self.parseStripTags(req.headers.striptags)) return
|
if (!self.parseStripTags(req.headers.striptags)) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Promise.all(filesData.map(async file =>
|
await Promise.all(filesData.map(async file => {
|
||||||
utils.stripTags(file.filename, file.extname)
|
// Update size attribute if applicable
|
||||||
))
|
const stat = await utils.stripTags(file.filename, file.extname)
|
||||||
|
if (stat) {
|
||||||
|
file.size = stat.size
|
||||||
|
}
|
||||||
|
}))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Unlink temp files (do not wait)
|
// Unlink temp files (do not wait)
|
||||||
Promise.all(filesData.map(async file =>
|
Promise.all(filesData.map(async file =>
|
||||||
|
@ -613,7 +613,7 @@ self.stripTags = async (name, extname) => {
|
|||||||
throw new ServerError('An error occurred while stripping tags. The format may not be supported.')
|
throw new ServerError('An error occurred while stripping tags. The format may not be supported.')
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return jetpack.inspectAsync(fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.unlinkFile = async (filename, predb) => {
|
self.unlinkFile = async (filename, predb) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user