refactor: address code review comments
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -200,7 +200,9 @@ async def process_url(request: URLUploadRequest):
|
|||||||
safe_filename = "download"
|
safe_filename = "download"
|
||||||
|
|
||||||
# Download file with security measures
|
# 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:
|
try:
|
||||||
logger.info(f"Downloading file from URL: {url}")
|
logger.info(f"Downloading file from URL: {url}")
|
||||||
|
|
||||||
|
|||||||
@@ -229,11 +229,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatBytes(bytes) {
|
function formatBytes(bytes) {
|
||||||
if (bytes === 0) return "0 Bytes";
|
// Reuse the existing formatFileSize function from upload.js
|
||||||
const k = 1024;
|
return formatFileSize(bytes);
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user