jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356597 )

Change subject: [Upgrade fixes] Prevent crash when upgrading from 2 versions 
ago.
......................................................................


[Upgrade fixes] Prevent crash when upgrading from 2 versions ago.

If the app is upgraded directly to the current version from a previous
version prior to the introduction of the saved-page cache delegate, it
crashes because the SavedPageSyncService wants to immediately call Stat on
the cache directory, when the directory doesn't exist yet (before any new
network calls are made).

This patch makes sure the cache directory gets created upon instantiating
the cache delegate, so that we can call Stat on it even before any network
requests are called.

Change-Id: I1e79fa7350fcaebc58120786417648cf703ee8ba
---
M app/src/main/java/okhttp3/CacheDelegate.java
1 file changed, 7 insertions(+), 0 deletions(-)

Approvals:
  Niedzielski: Looks good to me, approved
  jenkins-bot: Verified
  Mholloway: Looks good to me, but someone else must approve



diff --git a/app/src/main/java/okhttp3/CacheDelegate.java 
b/app/src/main/java/okhttp3/CacheDelegate.java
index 607c3ec..9689d8b 100644
--- a/app/src/main/java/okhttp3/CacheDelegate.java
+++ b/app/src/main/java/okhttp3/CacheDelegate.java
@@ -19,6 +19,13 @@
 
     public CacheDelegate(@NonNull Cache cache) {
         this.cache = cache;
+        if (!cache.cache.getDirectory().exists()) {
+            // When upgrading from previous versions where this cache didn't 
yet exist,
+            // make sure that the cache directory is created first.
+            // For example, SavedPageSyncService will immediately call Stat on 
this directory,
+            // which will cause a crash if it doesn't exist.
+            cache.cache.getDirectory().mkdirs();
+        }
     }
 
     @NonNull public DiskLruCache diskLruCache() {

-- 
To view, visit https://gerrit.wikimedia.org/r/356597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e79fa7350fcaebc58120786417648cf703ee8ba
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to