Mholloway has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378338 )

Change subject: Fix: Clear deleted offline pages from the save cache
......................................................................

Fix: Clear deleted offline pages from the save cache

SavedPageSyncService contains code to remove offline pages from the saved
page cache when they are deleted or toggled online-only. While investigat-
ing this issue, I noticed that toggling pages online-only resulted in them
being correctly removed from the save cache, but deleting the page or en-
tire list outright did not.

The cause is this: previously, when a reading list page was deleted, its
related DB entries would be deleted, and then we would kick off the sync
service. The trouble is that the sync service needs the page's db entry in
order to construct an OkHttp Request object to give to the CacheDelegate
for removal from the cache. If the DB entry is missing (say, because it's
already been deleted), the cache removal is skipped.

My proposed solution: stop deleting entries from the DB when their listKeys
field is empty. DB entries are cheap, especially compared to full saved
articles, and their hanging around even if the page is removed from all
lists will have only a vanishingly small effect on the user's disk space.

Also updates ReadingListData.findPageInAnyList to reflect that rows may
now be present in the DB but not in any list.

Bug: T164585
Change-Id: I60bf86f12a84faccdc532c30b2508bc1b3b42398
---
M app/src/main/java/org/wikipedia/readinglist/ReadingListData.java
M 
app/src/main/java/org/wikipedia/readinglist/page/database/ReadingListPageDao.java
2 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/38/378338/1

diff --git a/app/src/main/java/org/wikipedia/readinglist/ReadingListData.java 
b/app/src/main/java/org/wikipedia/readinglist/ReadingListData.java
index 8793fe6..bee536a 100644
--- a/app/src/main/java/org/wikipedia/readinglist/ReadingListData.java
+++ b/app/src/main/java/org/wikipedia/readinglist/ReadingListData.java
@@ -212,7 +212,10 @@
         try {
             if (cursor.getCount() != 0) {
                 cursor.moveToFirst();
-                return ReadingListPage.fromCursor(cursor);
+                ReadingListPage page = ReadingListPage.fromCursor(cursor);
+                if (!page.listKeys().isEmpty()) {
+                    return ReadingListPage.fromCursor(cursor);
+                }
             }
         } finally {
             cursor.close();
diff --git 
a/app/src/main/java/org/wikipedia/readinglist/page/database/ReadingListPageDao.java
 
b/app/src/main/java/org/wikipedia/readinglist/page/database/ReadingListPageDao.java
index bdb67da..830a151 100644
--- 
a/app/src/main/java/org/wikipedia/readinglist/page/database/ReadingListPageDao.java
+++ 
b/app/src/main/java/org/wikipedia/readinglist/page/database/ReadingListPageDao.java
@@ -99,7 +99,6 @@
         if (row.listKeys().isEmpty()) {
             httpDao.markDeleted(new ReadingListPageHttpRow(row));
             diskDao.markDeleted(new ReadingListPageDiskRow(row));
-            delete(row);
         } else {
             httpDao.markUpserted(new ReadingListPageHttpRow(row));
             if (row.diskStatus() == DiskStatus.OUTDATED) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I60bf86f12a84faccdc532c30b2508bc1b3b42398
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to