From 27131d15dddde1e78368601ff1efc774c9600087 Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 26 Jun 2018 12:25:53 -0700 Subject: [PATCH] -Updated room db to 1.1.1. -Fixed database import/export to no longer include accessory db files to ensure backward compatibility. --- app/build.gradle | 2 +- .../settings/ContentSettingsFragment.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ada2626f1..83abf44ab 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,7 +43,7 @@ android { ext { supportLibVersion = '27.1.1' exoPlayerLibVersion = '2.7.3' - roomDbLibVersion = '1.0.0' + roomDbLibVersion = '1.1.1' leakCanaryLibVersion = '1.5.4' okHttpLibVersion = '3.10.0' icepickLibVersion = '3.2.0' diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index a02a9df34..3894c421f 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -56,6 +56,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment { private File databasesDir; private File newpipe_db; private File newpipe_db_journal; + private File newpipe_db_shm; + private File newpipe_db_wal; private File newpipe_settings; private String thumbnailLoadToggleKey; @@ -88,6 +90,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment { databasesDir = new File(homeDir + "/databases"); newpipe_db = new File(homeDir + "/databases/newpipe.db"); newpipe_db_journal = new File(homeDir + "/databases/newpipe.db-journal"); + newpipe_db_shm = new File(homeDir + "/databases/newpipe.db-shm"); + newpipe_db_wal = new File(homeDir + "/databases/newpipe.db-wal"); + newpipe_settings = new File(homeDir + "/databases/newpipe.settings"); newpipe_settings.delete(); @@ -207,7 +212,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { new BufferedOutputStream( new FileOutputStream(path))); ZipHelper.addFileToZip(outZip, newpipe_db.getPath(), "newpipe.db"); - ZipHelper.addFileToZip(outZip, newpipe_db_journal.getPath(), "newpipe.db-journal"); + saveSharedPreferencesToFile(newpipe_settings); ZipHelper.addFileToZip(outZip, newpipe_settings.getPath(), "newpipe.settings"); @@ -263,8 +268,15 @@ public class ContentSettingsFragment extends BasePreferenceFragment { throw new Exception("Could not create databases dir"); } - if(!(ZipHelper.extractFileFromZip(filePath, newpipe_db.getPath(), "newpipe.db") - && ZipHelper.extractFileFromZip(filePath, newpipe_db_journal.getPath(), "newpipe.db-journal"))) { + final boolean isDbFileExtracted = ZipHelper.extractFileFromZip(filePath, + newpipe_db.getPath(), "newpipe.db"); + + if (isDbFileExtracted) { + newpipe_db_journal.delete(); + newpipe_db_wal.delete(); + newpipe_db_shm.delete(); + + } else { Toast.makeText(getContext(), R.string.could_not_import_all_files, Toast.LENGTH_LONG) .show(); }