From 47a1de953d09852d7c863fcf6ef9b82bec97b341 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 13:39:35 +0000 Subject: [PATCH] refactor: address code review comments Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- app/api/url_upload.py | 4 +++- frontend/templates/upload.html | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/api/url_upload.py b/app/api/url_upload.py index 6bf07d05..49934254 100644 --- a/app/api/url_upload.py +++ b/app/api/url_upload.py @@ -200,7 +200,9 @@ async def process_url(request: URLUploadRequest): safe_filename = "download" # Download file with security measures - target_path = None # Initialize to None for cleanup in exception handlers + # Initialize target_path to None to prevent UnboundLocalError in exception handlers + # that may execute before target_path is assigned during error cases + target_path = None try: logger.info(f"Downloading file from URL: {url}") diff --git a/frontend/templates/upload.html b/frontend/templates/upload.html index ed47a12a..552ca076 100644 --- a/frontend/templates/upload.html +++ b/frontend/templates/upload.html @@ -229,11 +229,8 @@ } function formatBytes(bytes) { - if (bytes === 0) return "0 Bytes"; - const k = 1024; - const sizes = ["Bytes", "KB", "MB", "GB"]; - const i = Math.floor(Math.log(bytes) / Math.log(k)); - return Math.round(bytes / Math.pow(k, i) * 100) / 100 + " " + sizes[i]; + // Reuse the existing formatFileSize function from upload.js + return formatFileSize(bytes); } {% endblock %}