Browse Source

Allow setting of a folder on Aria2 setups for reverse proxy users. Fixes #397.

pull/424/head
Eric Kok 7 years ago
parent
commit
bcc6fd460f
  1. 12
      app/src/main/java/org/transdroid/daemon/Aria2c/Aria2Adapter.java
  2. 2
      app/src/main/java/org/transdroid/daemon/Daemon.java
  3. 2
      app/src/main/java/org/transdroid/daemon/DaemonSettings.java

12
app/src/main/java/org/transdroid/daemon/Aria2c/Aria2Adapter.java

@ -106,7 +106,7 @@ public class Aria2Adapter implements IDaemonAdapter {
buildRequest("aria2.tellStopped", new JSONArray().put(0).put(9999).put(fields)); buildRequest("aria2.tellStopped", new JSONArray().put(0).put(9999).put(fields));
params.put(active).put(waiting).put(stopped); params.put(active).put(waiting).put(stopped);
List<Torrent> torrents = new ArrayList<Torrent>(); List<Torrent> torrents = new ArrayList<>();
JSONArray lists = makeRequestForArray(log, params.toString()); JSONArray lists = makeRequestForArray(log, params.toString());
for (int i = 0; i < lists.length(); i++) { for (int i = 0; i < lists.length(); i++) {
torrents.addAll(parseJsonRetrieveTorrents(lists.getJSONObject(i).getJSONArray("result"))); torrents.addAll(parseJsonRetrieveTorrents(lists.getJSONObject(i).getJSONArray("result")));
@ -322,10 +322,10 @@ public class Aria2Adapter implements IDaemonAdapter {
} }
private ArrayList<Torrent> parseJsonRetrieveTorrents(JSONArray response) throws JSONException, DaemonException { private ArrayList<Torrent> parseJsonRetrieveTorrents(JSONArray response) throws JSONException {
// Parse response // Parse response
ArrayList<Torrent> torrents = new ArrayList<Torrent>(); ArrayList<Torrent> torrents = new ArrayList<>();
for (int j = 0; j < response.length(); j++) { for (int j = 0; j < response.length(); j++) {
// Add the parsed torrent to the list // Add the parsed torrent to the list
@ -392,7 +392,7 @@ public class Aria2Adapter implements IDaemonAdapter {
private ArrayList<TorrentFile> parseJsonFileListing(JSONArray response, Torrent torrent) throws JSONException { private ArrayList<TorrentFile> parseJsonFileListing(JSONArray response, Torrent torrent) throws JSONException {
// Parse response // Parse response
ArrayList<TorrentFile> files = new ArrayList<TorrentFile>(); ArrayList<TorrentFile> files = new ArrayList<>();
for (int j = 0; j < response.length(); j++) { for (int j = 0; j < response.length(); j++) {
JSONObject file = response.getJSONObject(j); JSONObject file = response.getJSONObject(j);
@ -420,8 +420,8 @@ public class Aria2Adapter implements IDaemonAdapter {
private TorrentDetails parseJsonTorrentDetails(JSONObject response) throws JSONException { private TorrentDetails parseJsonTorrentDetails(JSONObject response) throws JSONException {
// Parse response // Parse response
List<String> trackers = new ArrayList<String>(); List<String> trackers = new ArrayList<>();
List<String> errors = new ArrayList<String>(); List<String> errors = new ArrayList<>();
int error = response.optInt("errorCode", 0); int error = response.optInt("errorCode", 0);
if (error > 0) { if (error > 0) {

2
app/src/main/java/org/transdroid/daemon/Daemon.java

@ -333,7 +333,7 @@ public enum Daemon {
} }
public static boolean supportsCustomFolder(Daemon type) { public static boolean supportsCustomFolder(Daemon type) {
return type == rTorrent || type == Tfb4rt || type == Bitflu || type == Deluge || type == DelugeRpc return type == rTorrent || type == Tfb4rt || type == Bitflu || type == Deluge || type == DelugeRpc || type == Aria2
|| type == Transmission || type == BitTorrent || type == uTorrent || type == qBittorrent || type == Dummy; || type == Transmission || type == BitTorrent || type == uTorrent || type == qBittorrent || type == Dummy;
} }

2
app/src/main/java/org/transdroid/daemon/DaemonSettings.java

@ -122,7 +122,7 @@ public final class DaemonSettings {
return sslTrustKey; return sslTrustKey;
} }
public String getFolder() { public String getFolder() {
return folder == null? null: (folder.startsWith("/")? folder: folder + "/"); return folder == null ? null : (folder.startsWith("/") ? folder : folder + "/");
} }
public boolean shouldUseAuthentication() { public boolean shouldUseAuthentication() {
return useAuthentication; return useAuthentication;

Loading…
Cancel
Save