From 153422f073223f4c82ac51a68fb7789df35ff55b Mon Sep 17 00:00:00 2001 From: piitex Date: Wed, 5 Nov 2025 20:41:42 -0600 Subject: [PATCH] getRemoteFileSize will now throw IOException instead of handling it. --- .../java/me/piitex/os/FileDownloader.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/piitex/os/FileDownloader.java b/src/main/java/me/piitex/os/FileDownloader.java index 057e7be..80c6cc1 100644 --- a/src/main/java/me/piitex/os/FileDownloader.java +++ b/src/main/java/me/piitex/os/FileDownloader.java @@ -140,21 +140,16 @@ public boolean cancelDownload(String fileUrl) { return wasRunning; } - public long getRemoteFileSize(String fileUrl) { - try { - URL url = new URL(fileUrl); - URLConnection connection = url.openConnection(); - connection.setConnectTimeout(5000); - if (connection instanceof HttpURLConnection) { - ((HttpURLConnection) connection).setRequestMethod("HEAD"); - } - connection.connect(); - - return connection.getContentLengthLong(); - } catch (Exception e) { - logger.error("Error fetching remote file size", e); - return -1; + public long getRemoteFileSize(String fileUrl) throws IOException { + URL url = new URL(fileUrl); + URLConnection connection = url.openConnection(); + connection.setConnectTimeout(5000); + if (connection instanceof HttpURLConnection) { + ((HttpURLConnection) connection).setRequestMethod("HEAD"); } + connection.connect(); + + return connection.getContentLengthLong(); } public void addDownloadListener(DownloadListener listener) {