Browse Source

Allow Transmission users to set a base dir for ftp download url construction; fixes #518

pull/565/head
Eric Kok 4 years ago
parent
commit
77af0273de
  1. 2
      app/src/main/java/org/transdroid/daemon/Daemon.java
  2. 21
      app/src/main/java/org/transdroid/daemon/Transmission/TransmissionAdapter.java

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

@ -329,7 +329,7 @@ public enum Daemon {
} }
public static boolean needsManualPathSpecified(Daemon type) { public static boolean needsManualPathSpecified(Daemon type) {
return type == uTorrent || type == BitTorrent || type == KTorrent || type == BuffaloNas; return type == uTorrent || type == BitTorrent || type == KTorrent || type == BuffaloNas || type == Transmission;
} }
public static boolean supportsFilePaths(Daemon type) { public static boolean supportsFilePaths(Daemon type) {

21
app/src/main/java/org/transdroid/daemon/Transmission/TransmissionAdapter.java

@ -17,13 +17,14 @@
*/ */
package org.transdroid.daemon.Transmission; package org.transdroid.daemon.Transmission;
import net.iharder.Base64;
import net.iharder.Base64.InputStream;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import net.iharder.Base64;
import net.iharder.Base64.InputStream;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -579,6 +580,18 @@ public class TransmissionAdapter implements IDaemonAdapter {
private ArrayList<TorrentFile> parseJsonFileList(JSONObject response, Torrent torrent) throws JSONException { private ArrayList<TorrentFile> parseJsonFileList(JSONObject response, Torrent torrent) throws JSONException {
String absoluteDir = torrent.getLocationDir();
String relativeDir = settings.getDownloadDir();
if (relativeDir == null) {
// We can make no assumptions except the torrent's location is the main download dir
relativeDir = "";
} else if (absoluteDir.startsWith(relativeDir)) {
relativeDir = absoluteDir.substring(relativeDir.length());
if (relativeDir.startsWith("/")) {
relativeDir = relativeDir.substring(1);
}
}
// Parse response // Parse response
ArrayList<TorrentFile> torrentfiles = new ArrayList<>(); ArrayList<TorrentFile> torrentfiles = new ArrayList<>();
JSONArray rarray = response.getJSONArray("torrents"); JSONArray rarray = response.getJSONArray("torrents");
@ -592,8 +605,8 @@ public class TransmissionAdapter implements IDaemonAdapter {
torrentfiles.add(new TorrentFile( torrentfiles.add(new TorrentFile(
String.valueOf(i), String.valueOf(i),
file.getString(RPC_FILE_NAME), file.getString(RPC_FILE_NAME),
file.getString(RPC_FILE_NAME), relativeDir + file.getString(RPC_FILE_NAME),
torrent.getLocationDir() + file.getString(RPC_FILE_NAME), absoluteDir + file.getString(RPC_FILE_NAME),
file.getLong(RPC_FILE_LENGTH), file.getLong(RPC_FILE_LENGTH),
file.getLong(RPC_FILE_COMPLETED), file.getLong(RPC_FILE_COMPLETED),
convertTransmissionPriority(stat.getBoolean(RPC_FILESTAT_WANTED), stat.getInt(RPC_FILESTAT_PRIORITY)))); convertTransmissionPriority(stat.getBoolean(RPC_FILESTAT_WANTED), stat.getInt(RPC_FILESTAT_PRIORITY))));

Loading…
Cancel
Save