From dfa78b3ff5ee5de3b4ebe8eb6efeceab89758f99 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Thu, 9 Jul 2020 15:50:41 +0200 Subject: [PATCH] Fix #550 by not crashing and assuming bytes instead --- .../transdroid/daemon/Qbittorrent/QbittorrentAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java index 83bb4407..14d3080f 100644 --- a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java @@ -760,7 +760,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { } private long parseSize(String string) { - // See https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-Documentation + // See https://github.com/qbittorrent/qBittorrent/wiki if (string.equals("Unknown")) return -1; // Sizes are given in "1,023.3 MiB"-like string format @@ -771,6 +771,10 @@ public class QbittorrentAdapter implements IDaemonAdapter { } catch (Exception e) { return -1L; } + if (parts.length <= 1) { + // Interpret as bytes, as no qualifier was given + return (long) number; + } // Returns size in B-based long if (parts[1].equals("TiB")) { return (long) (number * 1024L * 1024L * 1024L * 1024L);