mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-30 23:01:34 +00:00
feat: logger.debug() outputs only on dev mode
This commit is contained in:
parent
42c8a3e06c
commit
ffc82f6a2a
@ -200,7 +200,7 @@ self.getUniqueRandomName = async (length, extension) => {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
utils.idSet.add(identifier)
|
utils.idSet.add(identifier)
|
||||||
// logger.log(`Added ${identifier} to identifiers cache`)
|
logger.debug(`Added ${identifier} to identifiers cache`)
|
||||||
} else if (config.uploads.queryDbForFileCollisions) {
|
} else if (config.uploads.queryDbForFileCollisions) {
|
||||||
if (self.onHold.has(identifier)) continue
|
if (self.onHold.has(identifier)) continue
|
||||||
|
|
||||||
@ -613,22 +613,23 @@ self.cleanUpChunks = async (uuid, onTimeout) => {
|
|||||||
|
|
||||||
self.scanFiles = async (req, user, infoMap) => {
|
self.scanFiles = async (req, user, infoMap) => {
|
||||||
if (user && utils.clamscan.groupBypass && perms.is(user, utils.clamscan.groupBypass)) {
|
if (user && utils.clamscan.groupBypass && perms.is(user, utils.clamscan.groupBypass)) {
|
||||||
// logger.log(`[ClamAV]: Skipping ${infoMap.length} file(s), ${utils.clamscan.groupBypass} group bypass`)
|
logger.debug(`[ClamAV]: Skipping ${infoMap.length} file(s), ${utils.clamscan.groupBypass} group bypass`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const foundThreats = []
|
const foundThreats = []
|
||||||
const results = await Promise.all(infoMap.map(async info => {
|
const results = await Promise.all(infoMap.map(async info => {
|
||||||
if (utils.clamscan.whitelistExtensions && utils.clamscan.whitelistExtensions.includes(info.data.extname)) {
|
if (utils.clamscan.whitelistExtensions && utils.clamscan.whitelistExtensions.includes(info.data.extname)) {
|
||||||
return // logger.log(`[ClamAV]: Skipping ${info.data.filename}, extension whitelisted`)
|
logger.debug(`[ClamAV]: Skipping ${info.data.filename}, extension whitelisted`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.clamscan.maxSize && info.data.size > utils.clamscan.maxSize) {
|
if (utils.clamscan.maxSize && info.data.size > utils.clamscan.maxSize) {
|
||||||
return // logger.log(`[ClamAV]: Skipping ${info.data.filename}, size ${info.data.size} > ${utils.clamscan.maxSize}`)
|
logger.debug(`[ClamAV]: Skipping ${info.data.filename}, size ${info.data.size} > ${utils.clamscan.maxSize}`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await utils.clamscan.instance.is_infected(info.path)
|
logger.debug(`[ClamAV]: Scanning ${info.data.filename}\u2026`)
|
||||||
if (response.is_infected) {
|
|
||||||
logger.log(`[ClamAV]: ${info.data.filename}: ${response.viruses.join(', ')}`)
|
logger.log(`[ClamAV]: ${info.data.filename}: ${response.viruses.join(', ')}`)
|
||||||
foundThreats.push(...response.viruses)
|
foundThreats.push(...response.viruses)
|
||||||
}
|
}
|
||||||
@ -698,7 +699,7 @@ self.storeFilesToDb = async (req, res, user, infoMap) => {
|
|||||||
if (dbFile) {
|
if (dbFile) {
|
||||||
// Continue even when encountering errors
|
// Continue even when encountering errors
|
||||||
await utils.unlinkFile(info.data.filename).catch(logger.error)
|
await utils.unlinkFile(info.data.filename).catch(logger.error)
|
||||||
// logger.log(`Unlinked ${info.data.filename} since a duplicate named ${dbFile.name} exists`)
|
logger.debug(`Unlinked ${info.data.filename} since a duplicate named ${dbFile.name} exists`)
|
||||||
|
|
||||||
// If on /nojs route, append original file name reported by client
|
// If on /nojs route, append original file name reported by client
|
||||||
if (req.path === '/nojs') {
|
if (req.path === '/nojs') {
|
||||||
|
@ -396,7 +396,7 @@ self.unlinkFile = async (filename, predb) => {
|
|||||||
// Do not remove from identifiers cache on pre-db-deletion
|
// Do not remove from identifiers cache on pre-db-deletion
|
||||||
if (!predb && self.idSet) {
|
if (!predb && self.idSet) {
|
||||||
self.idSet.delete(identifier)
|
self.idSet.delete(identifier)
|
||||||
// logger.log(`Removed ${identifier} from identifiers cache (deleteFile)`)
|
logger.debug(`Removed ${identifier} from identifiers cache (deleteFile)`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const extname = self.extname(filename, true)
|
const extname = self.extname(filename, true)
|
||||||
@ -466,7 +466,7 @@ self.bulkDeleteFromDb = async (field, values, user) => {
|
|||||||
unlinked.forEach(file => {
|
unlinked.forEach(file => {
|
||||||
const identifier = file.name.split('.')[0]
|
const identifier = file.name.split('.')[0]
|
||||||
self.idSet.delete(identifier)
|
self.idSet.delete(identifier)
|
||||||
// logger.log(`Removed ${identifier} from identifiers cache (bulkDeleteFromDb)`)
|
logger.debug(`Removed ${identifier} from identifiers cache (bulkDeleteFromDb)`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,12 @@ self.error = (content, options = {}) => {
|
|||||||
write(content, options)
|
write(content, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.debug = (...args) => {
|
self.debug = (content, options = {}) => {
|
||||||
|
if (process.env.NODE_ENV !== 'development') return
|
||||||
|
write(content, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.inspect = (...args) => {
|
||||||
const options = {
|
const options = {
|
||||||
colors: true,
|
colors: true,
|
||||||
depth: Infinity
|
depth: Infinity
|
||||||
|
Loading…
Reference in New Issue
Block a user