diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-02 00:17:34 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-02 00:17:34 +0200 |
commit | 1d4f26ad9707518bfe8caf24326259adca06c741 (patch) | |
tree | a1cd210501c0bc20ae27f83e65bcd7e2902fd371 /main/src/cgeo | |
parent | bab24e2ce1644213830b1ec8814175b00f3e019d (diff) | |
download | cgeo-1d4f26ad9707518bfe8caf24326259adca06c741.zip cgeo-1d4f26ad9707518bfe8caf24326259adca06c741.tar.gz cgeo-1d4f26ad9707518bfe8caf24326259adca06c741.tar.bz2 |
Refresh the data of confirmed cached data
When cached data is confirmed valid by a 304 (use local copy) response
from the web server, reset the file date, since the file is as good as
new.
Diffstat (limited to 'main/src/cgeo')
-rw-r--r-- | main/src/cgeo/geocaching/network/HtmlImage.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java index 751c69e..6cb4b86 100644 --- a/main/src/cgeo/geocaching/network/HtmlImage.java +++ b/main/src/cgeo/geocaching/network/HtmlImage.java @@ -82,8 +82,13 @@ public class HtmlImage implements Html.ImageGetter { try { final File file = LocalStorage.getStorageFile(geocode, url, true, true); final HttpResponse httpResponse = Network.request(absoluteURL, null, false, file); - if (httpResponse != null && httpResponse.getStatusLine().getStatusCode() == 200) { - LocalStorage.saveEntityToFile(httpResponse, file); + if (httpResponse != null) { + final int statusCode = httpResponse.getStatusLine().getStatusCode(); + if (statusCode == 200) { + LocalStorage.saveEntityToFile(httpResponse, file); + } else if (statusCode == 304) { + file.setLastModified(System.currentTimeMillis()); + } } } catch (Exception e) { Log.e(Settings.tag, "HtmlImage.getDrawable (downloading from web)", e); |