Replace DB entries on conflict

In this way we could add previously unknown info such as the size.
This commit is contained in:
Gabriele M
2017-07-04 19:05:04 +02:00
parent 320112dae4
commit 311b2f7cfd

View File

@@ -138,7 +138,9 @@ public class UpdaterController implements UpdaterControllerInt {
if (contentLenght != null) { if (contentLenght != null) {
try { try {
long size = Long.parseLong(contentLenght); long size = Long.parseLong(contentLenght);
update.setFileSize(size); if (size > 0) {
update.setFileSize(size);
}
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.e(TAG, "Could not get content-length"); Log.e(TAG, "Could not get content-length");
} }
@@ -149,7 +151,7 @@ public class UpdaterController implements UpdaterControllerInt {
@Override @Override
public void run() { public void run() {
mUpdatesDbHelper.addUpdateWithOnConflict(update, mUpdatesDbHelper.addUpdateWithOnConflict(update,
SQLiteDatabase.CONFLICT_IGNORE); SQLiteDatabase.CONFLICT_REPLACE);
} }
}).start(); }).start();
notifyUpdateChange(downloadId); notifyUpdateChange(downloadId);