From 3a83cf8303461a433d5686571aafa321f88c463f Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 24 Mar 2017 18:51:37 +0000 Subject: [PATCH] Collection deletion: mark as deleted in cache, but don't actually delete. This is important for protecting against potential data loss. --- .../com/etesync/syncadapter/ui/DeleteCollectionFragment.java | 4 +++- .../com/etesync/syncadapter/ui/ViewCollectionActivity.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.java b/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.java index 48ddf73b..20d50926 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.java @@ -120,7 +120,9 @@ public class DeleteCollectionFragment extends DialogFragment implements LoaderMa JournalManager journalManager = new JournalManager(HttpClient.create(getContext(), account), principal); journalManager.deleteJournal(new JournalManager.Journal(settings.password(), collectionInfo.toJson(), collectionInfo.url)); - data.delete(JournalEntity.fetch(data, collectionInfo.url)); + JournalEntity journalEntity = JournalEntity.fetch(data, collectionInfo.url); + journalEntity.setDeleted(true); + data.update(journalEntity); return null; } catch (Exceptions.HttpException e) { diff --git a/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java index eb9bf189..77e952ed 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.java @@ -57,7 +57,7 @@ public class ViewCollectionActivity extends AppCompatActivity implements Refresh int entryCount = -1; final JournalEntity journalEntity = JournalEntity.fetch(data, info.url); - if (journalEntity == null) { + if ((journalEntity == null) || journalEntity.isDeleted()) { finish(); return; }