mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-23 05:39:05 +00:00
fix: internally prepend chunksData UUID with IP
even less chance for a collision to occur
This commit is contained in:
parent
2f48becf23
commit
46c8867223
@ -360,8 +360,10 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file.isChunk) {
|
if (file.isChunk) {
|
||||||
|
// Re-map UUID property to IP-specific UUID
|
||||||
|
const uuid = `${req.ip}_${req.body.uuid}`
|
||||||
// Calling initChunks() will also reset the chunked uploads' timeout
|
// Calling initChunks() will also reset the chunked uploads' timeout
|
||||||
file.chunksData = await initChunks(req.body.uuid)
|
file.chunksData = await initChunks(uuid)
|
||||||
file.filename = file.chunksData.filename
|
file.filename = file.chunksData.filename
|
||||||
file.path = file.chunksData.path
|
file.path = file.chunksData.path
|
||||||
} else {
|
} else {
|
||||||
@ -441,7 +443,7 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
|||||||
// Clean up temp files and held identifiers (do not wait)
|
// Clean up temp files and held identifiers (do not wait)
|
||||||
cleanUpFiles()
|
cleanUpFiles()
|
||||||
|
|
||||||
// res.multipart() itself may throw string errors
|
// Response.multipart() itself may throw string errors
|
||||||
if (typeof error === 'string') {
|
if (typeof error === 'string') {
|
||||||
throw new ClientError(error)
|
throw new ClientError(error)
|
||||||
} else {
|
} else {
|
||||||
@ -454,13 +456,15 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If chunked uploads is enabled and the uploaded file is a chunk, then just say that it was a success
|
// If chunked uploads is enabled and the uploaded file is a chunk, then just say that it was a success
|
||||||
const uuid = req.body.uuid
|
// NOTE: We loop through Request.files for clarity,
|
||||||
if (chunkedUploads && chunksData[uuid] !== undefined) {
|
// but we will actually have already rejected the Request
|
||||||
|
// if it has more than 1 file while being a chunk upload
|
||||||
|
if (chunkedUploads && req.files.some(file => file.isChunk)) {
|
||||||
req.files.forEach(file => {
|
req.files.forEach(file => {
|
||||||
chunksData[uuid].chunks++
|
file.chunksData.chunks++
|
||||||
|
// Mark as ready to accept more chunk uploads or to finalize
|
||||||
|
file.chunksData.processing = false
|
||||||
})
|
})
|
||||||
// Mark as ready to accept more chunk uploads or to finalize
|
|
||||||
chunksData[uuid].processing = false
|
|
||||||
return res.json({ success: true })
|
return res.json({ success: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,6 +705,11 @@ self.finishChunks = async (req, res) => {
|
|||||||
throw new ClientError('Bad request.')
|
throw new ClientError('Bad request.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-map UUID property to IP-specific UUID
|
||||||
|
files.forEach(file => {
|
||||||
|
file.uuid = `${req.ip}_${file.uuid}`
|
||||||
|
})
|
||||||
|
|
||||||
return self.actuallyFinishChunks(req, res, user, files)
|
return self.actuallyFinishChunks(req, res, user, files)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Unlink temp files (do not wait)
|
// Unlink temp files (do not wait)
|
||||||
|
Loading…
Reference in New Issue
Block a user