Browse Source

Fix #550 by not crashing and assuming bytes instead

pull/565/head
Eric Kok 4 years ago
parent
commit
dfa78b3ff5
  1. 6
      app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

6
app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -760,7 +760,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -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 { @@ -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);

Loading…
Cancel
Save