fix: passthrough scan

This commit is contained in:
Bobby 2022-04-16 13:33:11 +07:00
parent dd6f225461
commit b5aa8d0758
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
2 changed files with 5 additions and 3 deletions

View File

@ -627,8 +627,10 @@ self.assertPassthroughScans = async (req, user, infoMap) => {
for (const info of infoMap) {
if (info.data.clamscan) {
if (info.data.clamscan.isInfected) {
logger.log(`[ClamAV]: ${info.data.filename}: ${info.data.clamscan.viruses.join(', ')}`)
foundThreats.push(...info.data.clamscan.viruses)
} else if (info.data.clamscan.isInfected === null) {
logger.log(`[ClamAV]: ${info.data.filename}: Unable to scan`)
unableToScan.push(info.data.filename)
}
} else {

View File

@ -26,7 +26,7 @@ DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) {
let tempError = null
let tempObject = {}
let tempWeight = 0
const _cb = (err = null, result = {}, weight = 1) => {
const _cb = (err = null, result = {}, weight = 2) => {
tempError = err
tempWeight += weight
tempObject = Object.assign(result, tempObject)
@ -75,7 +75,7 @@ DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) {
destination,
filename,
path: finalPath
}, 2)
})
})
file.stream.pipe(outStream, { end: false })
} else {
@ -95,7 +95,7 @@ DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) {
clamStream.on('scan-complete', result => {
_cb(null, {
clamscan: result
})
}, 1)
})
file.stream.pipe(clamStream).pipe(outStream)
} else {