diff --git a/app/build.gradle b/app/build.gradle index 120482498..227408c8a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,12 +21,12 @@ android { leanback { dimension "mode" versionCode 207 - versionName "20231104#4" + versionName "20231104#5" } mobile { dimension "mode" versionCode 207 - versionName "20231104#4" + versionName "20231104#5" } java { dimension "api" diff --git a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java index 42b79c811..035e8da02 100644 --- a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java +++ b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java @@ -51,29 +51,25 @@ public abstract class AppDatabase extends RoomDatabase { public static void backup(com.fongmi.android.tv.impl.Callback callback) { App.execute(() -> { - if (get().isOpen()) get().close(); File db = App.get().getDatabasePath(NAME).getAbsoluteFile(); File wal = App.get().getDatabasePath(NAME + "-wal").getAbsoluteFile(); File shm = App.get().getDatabasePath(NAME + "-shm").getAbsoluteFile(); - boolean exists = db.exists() && wal.exists() && shm.exists(); - if (exists) Path.copy(db, new File(Path.tv(), db.getName())); - if (exists) Path.copy(wal, new File(Path.tv(), wal.getName())); - if (exists) Path.copy(shm, new File(Path.tv(), shm.getName())); - if (exists) App.post(callback::success); + if (db.exists()) Path.copy(db, new File(Path.tv(), db.getName())); + if (wal.exists()) Path.copy(wal, new File(Path.tv(), wal.getName())); + if (shm.exists()) Path.copy(shm, new File(Path.tv(), shm.getName())); + if (db.exists()) App.post(callback::success); }); } public static void restore(com.fongmi.android.tv.impl.Callback callback) { App.execute(() -> { - if (get().isOpen()) get().close(); File db = new File(Path.tv(), NAME); File wal = new File(Path.tv(), NAME + "-wal"); File shm = new File(Path.tv(), NAME + "-shm"); - boolean exists = db.exists() && wal.exists() && shm.exists(); - if (exists) Path.copy(db, App.get().getDatabasePath(db.getName()).getAbsoluteFile()); - if (exists) Path.copy(wal, App.get().getDatabasePath(wal.getName()).getAbsoluteFile()); - if (exists) Path.copy(shm, App.get().getDatabasePath(shm.getName()).getAbsoluteFile()); - if (exists) App.post(callback::success); + if (db.exists()) Path.copy(db, App.get().getDatabasePath(db.getName()).getAbsoluteFile()); + if (wal.exists()) Path.copy(wal, App.get().getDatabasePath(wal.getName()).getAbsoluteFile()); + if (shm.exists()) Path.copy(shm, App.get().getDatabasePath(shm.getName()).getAbsoluteFile()); + if (db.exists()) App.post(callback::success); }); }