Skip to content

Commit

Permalink
Fix conf icon fetch: It was never getting cached because I wasn't com…
Browse files Browse the repository at this point in the history
…pleting the request. Pretty sure that was required with my old `Fetcher` as well so boo for me deleting too much code!
  • Loading branch information
Wilm0r committed Sep 5, 2023
1 parent dc46d0e commit a8832cd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
15 changes: 13 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/main/java/net/gaast/giggity/Fetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.http.HttpResponseCache;
import android.os.Handler;
import android.os.Looper;
Expand Down Expand Up @@ -123,6 +122,7 @@ public Fetcher(Giggity app_, String url, Source source) throws IOException {

String status = dlc.getResponseCode() + " " + dlc.getResponseMessage();
Log.d("Fetcher", "HTTP status " + status);
// Log.d("Fetcher", "Req " + cache.getRequestCount() + " Net " + cache.getNetworkCount() + " Hit " + cache.getHitCount());
String loc = dlc.getHeaderField("Location");
if (loc != null) {
Log.d("http-location", loc);
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/net/gaast/giggity/ScheduleUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.util.Log;
import android.view.View;

import org.apache.commons.io.output.NullOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.time.ZoneId;
Expand Down Expand Up @@ -120,6 +122,9 @@ public void run() {
Fetcher f;
try {
f = new Fetcher(app, getIconUrl(), Fetcher.Source.DEFAULT);
// Just feed it to /dev/null so that next time we can CACHE_ONLY fetch it.
// It won't get cached without completing this bogus read!
Giggity.copy(f.getStream(), new NullOutputStream());
} catch (IOException e) {
Log.e("getIconStream", "Fetch error: " + e);
return;
Expand Down

0 comments on commit a8832cd

Please sign in to comment.