From 76a45fa6ac3e8c42dfb5ab65c7484b96d40ddb62 Mon Sep 17 00:00:00 2001
From: naskya <m@naskya.net>
Date: Thu, 25 Apr 2024 11:08:45 +0900
Subject: [PATCH] chore (backend): move download logs to debug

---
 packages/backend/src/misc/download-url.ts | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/packages/backend/src/misc/download-url.ts b/packages/backend/src/misc/download-url.ts
index d79d6a349e..0a47395947 100644
--- a/packages/backend/src/misc/download-url.ts
+++ b/packages/backend/src/misc/download-url.ts
@@ -14,9 +14,9 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
 		throw new StatusError("Invalid URL", 400);
 	}
 
-	const logger = new Logger("download");
+	const downloadLogger = new Logger("download");
 
-	logger.info(`Downloading ${chalk.cyan(url)} ...`);
+	downloadLogger.debug(`Downloading ${chalk.cyan(url)} ...`);
 
 	const timeout = 30 * 1000;
 	const operationTimeout = 60 * 1000;
@@ -45,7 +45,7 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
 		})
 		.on("redirect", (res: Got.Response, opts: Got.NormalizedOptions) => {
 			if (!isValidUrl(opts.url)) {
-				logger.warn(`Invalid URL: ${opts.url}`);
+				downloadLogger.warn(`Invalid URL: ${opts.url}`);
 				req.destroy();
 			}
 		})
@@ -57,7 +57,7 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
 				res.ip
 			) {
 				if (isPrivateIp(res.ip)) {
-					logger.warn(`Blocked address: ${res.ip}`);
+					downloadLogger.warn(`Blocked address: ${res.ip}`);
 					req.destroy();
 				}
 			}
@@ -66,14 +66,16 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
 			if (contentLength != null) {
 				const size = Number(contentLength);
 				if (size > maxSize) {
-					logger.warn(`maxSize exceeded (${size} > ${maxSize}) on response`);
+					downloadLogger.warn(
+						`maxSize exceeded (${size} > ${maxSize}) on response`,
+					);
 					req.destroy();
 				}
 			}
 		})
 		.on("downloadProgress", (progress: Got.Progress) => {
 			if (progress.transferred > maxSize) {
-				logger.warn(
+				downloadLogger.warn(
 					`maxSize exceeded (${progress.transferred} > ${maxSize}) on downloadProgress`,
 				);
 				req.destroy();
@@ -94,7 +96,7 @@ export async function downloadUrl(url: string, path: string): Promise<void> {
 		}
 	}
 
-	logger.info(`Download finished: ${chalk.cyan(url)}`);
+	downloadLogger.debug(`Download finished: ${chalk.cyan(url)}`);
 }
 
 export function isPrivateIp(ip: string): boolean {