From b9b3908dc3b7d071b485d5169942113f7d709468 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Thu, 21 Jul 2016 11:19:58 +1000 Subject: [PATCH] Prevent crash for servers that don't send etags with repo indexes Always capture timestamps, even if it is the same. This is because we are dependent on it later on in the repo update process. Specifically, when updating from a HTTP server that doesn't send out etags with its responses, it will trigger a full blown repo update every time, even if all the values in the index are the same (name, description, etc). This is as distinct from better behaving servers that send etags, in which case we will only do a partial update (i.e. persist the "last updated time"). In such a case, the remainder of the update process will proceed, and ask for this timestamp. --- app/src/main/java/org/fdroid/fdroid/RepoUpdater.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java index 3df518df1..3d6e85fcf 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java @@ -278,9 +278,13 @@ public class RepoUpdater { values.put(RepoTable.Cols.NAME, name); } - if (timestamp != repo.timestamp) { - values.put(RepoTable.Cols.TIMESTAMP, timestamp); - } + // Always put a timestamp here, even if it is the same. This is because we are dependent + // on it later on in the process. Specifically, when updating from a HTTP server that + // doesn't send out etags with its responses, it will trigger a full blown repo update + // every time, even if all the values in the index are the same (name, description, etc). + // In such a case, the remainder of the update process will proceed, and ask for this + // timestamp. + values.put(RepoTable.Cols.TIMESTAMP, timestamp); return values; }