feat: console logs for identifiers on debug only

This commit is contained in:
Bobby 2022-07-30 08:35:26 +07:00
parent 548af312a7
commit b7dcf30578
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
2 changed files with 7 additions and 5 deletions

View File

@ -50,7 +50,7 @@ self.getUniqueAlbumIdentifier = async res => {
const identifier = randomstring.generate(config.uploads.albumIdentifierLength)
if (self.onHold.has(identifier)) {
logger.log(`Identifier ${identifier} is currently held by another album (${i + 1}/${utils.idMaxTries}).`)
logger.debug(`Identifier ${identifier} is currently held by another album (${i + 1}/${utils.idMaxTries}).`)
continue
}
@ -63,12 +63,14 @@ self.getUniqueAlbumIdentifier = async res => {
.first()
if (album) {
self.onHold.delete(identifier)
logger.log(`Album with identifier ${identifier} already exists (${i + 1}/${utils.idMaxTries}).`)
logger.debug(`Album with identifier ${identifier} already exists (${i + 1}/${utils.idMaxTries}).`)
continue
}
// Unhold identifier once the Response has been sent
if (res) {
// Keep in an array for future-proofing
// if a single Request needs to generate multiple album identifiers
if (!res.locals.identifiers) {
res.locals.identifiers = []
res.once('finish', () => { self.unholdAlbumIdentifiers(res) })

View File

@ -157,7 +157,7 @@ self.getUniqueUploadIdentifier = async (length, extension = '', res) => {
if (queryDatabaseForIdentifierMatch) {
// If must query database for identifiers matches
if (self.onHold.has(identifier)) {
logger.log(`Identifier ${identifier} is currently held by another upload (${i + 1}/${utils.idMaxTries}).`)
logger.debug(`Identifier ${identifier} is currently held by another upload (${i + 1}/${utils.idMaxTries}).`)
continue
}
@ -170,7 +170,7 @@ self.getUniqueUploadIdentifier = async (length, extension = '', res) => {
.first()
if (file) {
self.onHold.delete(identifier)
logger.log(`Identifier ${identifier} is already in use (${i + 1}/${utils.idMaxTries}).`)
logger.debug(`Identifier ${identifier} is already in use (${i + 1}/${utils.idMaxTries}).`)
continue
}
@ -187,7 +187,7 @@ self.getUniqueUploadIdentifier = async (length, extension = '', res) => {
try {
const name = identifier + extension
await paths.access(path.join(paths.uploads, name))
logger.log(`${name} is already in use (${i + 1}/${utils.idMaxTries}).`)
logger.debug(`${name} is already in use (${i + 1}/${utils.idMaxTries}).`)
continue
} catch (error) {
// Re-throw non-ENOENT error