fixed downloading of deleted files

This commit is contained in:
Daniel Gultsch 2019-01-10 18:23:09 +01:00
parent a644b40c3e
commit 8ab4ca7138
2 changed files with 4 additions and 3 deletions

View file

@ -369,9 +369,10 @@ public class HttpDownloadConnection implements Transferable {
} }
connection.setUseCaches(false); connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getUserAgent()); connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getUserAgent());
final boolean tryResume = file.exists() && file.getKey() == null && file.getSize() > 0; final long expected = file.getExpectedSize();
final boolean tryResume = file.exists() && file.getKey() == null && file.getSize() > 0 && file.getSize() < expected;
long resumeSize = 0; long resumeSize = 0;
long expected = file.getExpectedSize();
if (tryResume) { if (tryResume) {
resumeSize = file.getSize(); resumeSize = file.getSize();
Log.d(Config.LOGTAG, "http download trying resume after" + resumeSize + " of " + expected); Log.d(Config.LOGTAG, "http download trying resume after" + resumeSize + " of " + expected);

View file

@ -1422,7 +1422,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
Log.d(Config.LOGTAG, "type: " + transferable.getClass().getName()); Log.d(Config.LOGTAG, "type: " + transferable.getClass().getName());
Toast.makeText(getActivity(), R.string.not_connected_try_again, Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), R.string.not_connected_try_again, Toast.LENGTH_SHORT).show();
} }
} else if (message.treatAsDownloadable()) { } else if (message.treatAsDownloadable() || message.hasFileOnRemoteHost()) {
createNewConnection(message); createNewConnection(message);
} }
} }