Skip to content

Commit 153e482

Browse files
authored
Merge pull request TeamNewPipe#12816 from TeamNewPipe/dbFix
Minor fixes for database
2 parents 89a68d0 + 93f03ba commit 153e482

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

app/src/main/java/org/schabi/newpipe/database/history/dao/HistoryDAO.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/database/history/dao/SearchHistoryDAO.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ package org.schabi.newpipe.database.history.dao
99
import androidx.room.Dao
1010
import androidx.room.Query
1111
import io.reactivex.rxjava3.core.Flowable
12+
import org.schabi.newpipe.database.BasicDAO
1213
import org.schabi.newpipe.database.history.model.SearchHistoryEntry
1314

1415
@Dao
15-
interface SearchHistoryDAO : HistoryDAO<SearchHistoryEntry> {
16+
interface SearchHistoryDAO : BasicDAO<SearchHistoryEntry> {
1617

1718
@get:Query("SELECT * FROM search_history WHERE id = (SELECT MAX(id) FROM search_history)")
18-
override val latestEntry: SearchHistoryEntry
19+
val latestEntry: SearchHistoryEntry?
1920

2021
@Query("DELETE FROM search_history")
2122
override fun deleteAll(): Int

app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import androidx.room.Dao
1010
import androidx.room.Query
1111
import androidx.room.RewriteQueriesToDropUnusedColumns
1212
import io.reactivex.rxjava3.core.Flowable
13+
import org.schabi.newpipe.database.BasicDAO
1314
import org.schabi.newpipe.database.history.model.StreamHistoryEntity
1415
import org.schabi.newpipe.database.history.model.StreamHistoryEntry
1516
import org.schabi.newpipe.database.stream.StreamStatisticsEntry
1617

1718
@Dao
18-
abstract class StreamHistoryDAO : HistoryDAO<StreamHistoryEntity> {
19-
20-
@get:Query("SELECT * FROM stream_history WHERE access_date = (SELECT MAX(access_date) FROM stream_history)")
21-
abstract override val latestEntry: StreamHistoryEntity
19+
abstract class StreamHistoryDAO : BasicDAO<StreamHistoryEntity> {
2220

2321
@Query("SELECT * FROM stream_history")
2422
abstract override fun getAll(): Flowable<List<StreamHistoryEntity>>

app/src/main/java/org/schabi/newpipe/settings/BackupRestoreSettingsFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import java.util.Date;
4141
import java.util.Locale;
4242
import java.util.Objects;
43+
import java.util.concurrent.ExecutorService;
44+
import java.util.concurrent.Executors;
4345

4446
public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
4547

@@ -155,9 +157,9 @@ private void requestImportPathResult(final ActivityResult result) {
155157
}
156158

157159
private void exportDatabase(final StoredFileHelper file, final Uri exportDataUri) {
158-
try {
160+
try (ExecutorService executor = Executors.newSingleThreadExecutor()) {
159161
//checkpoint before export
160-
NewPipeDatabase.checkpoint();
162+
executor.submit(NewPipeDatabase::checkpoint).get();
161163

162164
final SharedPreferences preferences = PreferenceManager
163165
.getDefaultSharedPreferences(requireContext());

0 commit comments

Comments
 (0)