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 11 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
@Background @Background
protected void refreshTorrents() { protected void refreshTorrents() {
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = RetrieveTask.create(currentConnection).execute(); 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) { if (result instanceof RetrieveTaskSuccessResult) {
onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(), onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(),
((RetrieveTaskSuccessResult) result).getLabels()); ((RetrieveTaskSuccessResult) result).getLabels());
@ -827,7 +832,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void refreshTorrentDetails(Torrent torrent) { public void refreshTorrentDetails(Torrent torrent) {
if (!Daemon.supportsFineDetails(currentConnection.getType())) if (!Daemon.supportsFineDetails(currentConnection.getType()))
return; return;
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = GetTorrentDetailsTask.create(currentConnection, torrent).execute(); 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) { if (result instanceof GetTorrentDetailsTaskSuccessResult) {
onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails()); onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails());
} else { } else {
@ -839,7 +849,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void refreshTorrentFiles(Torrent torrent) { public void refreshTorrentFiles(Torrent torrent) {
if (!Daemon.supportsFileListing(currentConnection.getType())) if (!Daemon.supportsFileListing(currentConnection.getType()))
return; return;
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = GetFileListTask.create(currentConnection, torrent).execute(); 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) { if (result instanceof GetFileListTaskSuccessResult) {
onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles()); onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles());
} else { } else {
@ -849,7 +864,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Background @Background
protected void getAdditionalStats() { protected void getAdditionalStats() {
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = GetStatsTask.create(currentConnection).execute(); 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) { if (result instanceof GetStatsTaskSuccessResult) {
onTurtleModeRetrieved(((GetStatsTaskSuccessResult) result).isAlternativeModeEnabled()); onTurtleModeRetrieved(((GetStatsTaskSuccessResult) result).isAlternativeModeEnabled());
} else { } else {
@ -859,7 +879,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Background @Background
protected void updateTurtleMode(boolean enable) { protected void updateTurtleMode(boolean enable) {
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = SetAlternativeModeTask.create(currentConnection, enable).execute(); 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) { if (result instanceof DaemonTaskSuccessResult) {
// Success; no need to retrieve it again - just update the visual indicator // Success; no need to retrieve it again - just update the visual indicator
onTurtleModeRetrieved(enable); onTurtleModeRetrieved(enable);

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

@ -319,7 +319,7 @@ public class SynologyAdapter implements IDaemonAdapter {
totalPeers, totalPeers,
eta.intValue(), eta.intValue(),
downloaded, downloaded,
Integer.parseInt(transfer.getString("size_uploaded")), transfer.getLong("size_uploaded"),
size, size,
(size == 0) ? 0 : (new Float(downloaded) / size), (size == 0) ? 0 : (new Float(downloaded) / size),
0, 0,

Loading…
Cancel
Save