Browse Source

Fix possible crash with Synology if the uploaded amount is larger than a 32-bit int will hold (~2GB).

pull/148/merge
Eric Kok 10 years ago
parent
commit
b07f5b4ce1
  1. 25
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  2. 2
      lib/src/org/transdroid/daemon/Synology/SynologyAdapter.java

25
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -814,7 +814,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);

2
lib/src/org/transdroid/daemon/Synology/SynologyAdapter.java

@ -319,7 +319,7 @@ public class SynologyAdapter implements IDaemonAdapter { @@ -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,

Loading…
Cancel
Save