mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 09:41:33 +00:00
fix: ipv6 support for chunked uploads
This commit is contained in:
parent
cf38c8ac50
commit
2a8901a903
@ -372,7 +372,7 @@ self.actuallyUpload = async (req, res, data = {}) => {
|
|||||||
const isChunk = typeof req.body.uuid === 'string' && Boolean(req.body.uuid)
|
const isChunk = typeof req.body.uuid === 'string' && Boolean(req.body.uuid)
|
||||||
if (isChunk) {
|
if (isChunk) {
|
||||||
// Re-map UUID property to IP-specific UUID
|
// Re-map UUID property to IP-specific UUID
|
||||||
const uuid = `${req.ip}_${req.body.uuid}`
|
const uuid = `${utils.pathSafeIp(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(uuid)
|
file.chunksData = await initChunks(uuid)
|
||||||
file.filename = file.chunksData.filename
|
file.filename = file.chunksData.filename
|
||||||
@ -759,7 +759,7 @@ self.finishChunks = async (req, res) => {
|
|||||||
|
|
||||||
// Re-map UUID property to IP-specific UUID
|
// Re-map UUID property to IP-specific UUID
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
file.uuid = `${req.ip}_${file.uuid}`
|
file.uuid = `${utils.pathSafeIp(req.ip)}_${file.uuid}`
|
||||||
file.chunksData = chunksData[file.uuid]
|
file.chunksData = chunksData[file.uuid]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -364,6 +364,12 @@ self.mask = string => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.pathSafeIp = ip => {
|
||||||
|
// Mainly intended for IPv6 addresses
|
||||||
|
if (!ip) return ''
|
||||||
|
return ip.replace(/:/g, '-')
|
||||||
|
}
|
||||||
|
|
||||||
self.filterUniquifySqlArray = (value, index, array) => {
|
self.filterUniquifySqlArray = (value, index, array) => {
|
||||||
return value !== null &&
|
return value !== null &&
|
||||||
value !== undefined &&
|
value !== undefined &&
|
||||||
|
Loading…
Reference in New Issue
Block a user