diff --git a/core/src/org/transdroid/core/gui/TorrentsActivity.java b/core/src/org/transdroid/core/gui/TorrentsActivity.java index 37a15060..994bb528 100644 --- a/core/src/org/transdroid/core/gui/TorrentsActivity.java +++ b/core/src/org/transdroid/core/gui/TorrentsActivity.java @@ -814,7 +814,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @Background protected void refreshTorrents() { + String startConnectionId = currentConnection.getSettings().getIdString(); DaemonTaskResult result = RetrieveTask.create(currentConnection).execute(); + if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) { + // During the command execution the user changed the server, so we are no longer interested in the result + return; + } if (result instanceof RetrieveTaskSuccessResult) { onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(), ((RetrieveTaskSuccessResult) result).getLabels()); @@ -827,7 +832,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi public void refreshTorrentDetails(Torrent torrent) { if (!Daemon.supportsFineDetails(currentConnection.getType())) return; + String startConnectionId = currentConnection.getSettings().getIdString(); DaemonTaskResult result = GetTorrentDetailsTask.create(currentConnection, torrent).execute(); + if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) { + // During the command execution the user changed the server, so we are no longer interested in the result + return; + } if (result instanceof GetTorrentDetailsTaskSuccessResult) { onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails()); } else { @@ -839,7 +849,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi public void refreshTorrentFiles(Torrent torrent) { if (!Daemon.supportsFileListing(currentConnection.getType())) return; + String startConnectionId = currentConnection.getSettings().getIdString(); DaemonTaskResult result = GetFileListTask.create(currentConnection, torrent).execute(); + if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) { + // During the command execution the user changed the server, so we are no longer interested in the result + return; + } if (result instanceof GetFileListTaskSuccessResult) { onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles()); } else { @@ -849,7 +864,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @Background protected void getAdditionalStats() { + String startConnectionId = currentConnection.getSettings().getIdString(); DaemonTaskResult result = GetStatsTask.create(currentConnection).execute(); + if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) { + // During the command execution the user changed the server, so we are no longer interested in the result + return; + } if (result instanceof GetStatsTaskSuccessResult) { onTurtleModeRetrieved(((GetStatsTaskSuccessResult) result).isAlternativeModeEnabled()); } else { @@ -859,7 +879,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @Background protected void updateTurtleMode(boolean enable) { + String startConnectionId = currentConnection.getSettings().getIdString(); DaemonTaskResult result = SetAlternativeModeTask.create(currentConnection, enable).execute(); + if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) { + // During the command execution the user changed the server, so we are no longer interested in the result + return; + } if (result instanceof DaemonTaskSuccessResult) { // Success; no need to retrieve it again - just update the visual indicator onTurtleModeRetrieved(enable); diff --git a/lib/src/org/transdroid/daemon/Synology/SynologyAdapter.java b/lib/src/org/transdroid/daemon/Synology/SynologyAdapter.java index 6db4ce80..0abb196e 100644 --- a/lib/src/org/transdroid/daemon/Synology/SynologyAdapter.java +++ b/lib/src/org/transdroid/daemon/Synology/SynologyAdapter.java @@ -319,7 +319,7 @@ public class SynologyAdapter implements IDaemonAdapter { totalPeers, eta.intValue(), downloaded, - Integer.parseInt(transfer.getString("size_uploaded")), + transfer.getLong("size_uploaded"), size, (size == 0) ? 0 : (new Float(downloaded) / size), 0,