mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-21 20:27:06 +03:00
Add option to backup non-library read entries
Co-authored-by: Roshan Varughese <40583749+Animeboynz@users.noreply.github.com> Co-authored-by: jobobby04 <jobobby04@gmail.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
parent
ddbdba3f61
commit
f25f6b3e29
9 changed files with 62 additions and 7 deletions
|
@ -35,8 +35,10 @@ import tachiyomi.core.common.util.system.logcat
|
|||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.entries.anime.interactor.GetAnimeFavorites
|
||||
import tachiyomi.domain.entries.anime.model.Anime
|
||||
import tachiyomi.domain.entries.anime.repository.AnimeRepository
|
||||
import tachiyomi.domain.entries.manga.interactor.GetMangaFavorites
|
||||
import tachiyomi.domain.entries.manga.model.Manga
|
||||
import tachiyomi.domain.entries.manga.repository.MangaRepository
|
||||
import tachiyomi.i18n.MR
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -54,6 +56,8 @@ class BackupCreator(
|
|||
private val getAnimeFavorites: GetAnimeFavorites = Injekt.get(),
|
||||
private val getMangaFavorites: GetMangaFavorites = Injekt.get(),
|
||||
private val backupPreferences: BackupPreferences = Injekt.get(),
|
||||
private val mangaRepository: MangaRepository = Injekt.get(),
|
||||
private val animeRepository: AnimeRepository = Injekt.get(),
|
||||
|
||||
private val animeCategoriesBackupCreator: AnimeCategoriesBackupCreator = AnimeCategoriesBackupCreator(),
|
||||
private val mangaCategoriesBackupCreator: MangaCategoriesBackupCreator = MangaCategoriesBackupCreator(),
|
||||
|
@ -89,8 +93,19 @@ class BackupCreator(
|
|||
throw IllegalStateException(context.stringResource(MR.strings.create_backup_file_error))
|
||||
}
|
||||
|
||||
val backupAnime = backupAnimes(getAnimeFavorites.await(), options)
|
||||
val backupManga = backupMangas(getMangaFavorites.await(), options)
|
||||
val nonFavoriteAnime = if (options.readEntries) {
|
||||
animeRepository.getWatchedAnimeNotInLibrary()
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
val backupAnime = backupAnimes(getAnimeFavorites.await() + nonFavoriteAnime, options)
|
||||
val nonFavoriteManga = if (options.readEntries) {
|
||||
mangaRepository.getReadMangaNotInLibrary()
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
val backupManga = backupMangas(getMangaFavorites.await() + nonFavoriteManga, options)
|
||||
|
||||
val backup = Backup(
|
||||
backupManga = backupManga,
|
||||
backupCategories = backupMangaCategories(options),
|
||||
|
|
|
@ -10,6 +10,7 @@ data class BackupOptions(
|
|||
val chapters: Boolean = true,
|
||||
val tracking: Boolean = true,
|
||||
val history: Boolean = true,
|
||||
val readEntries: Boolean = true,
|
||||
val appSettings: Boolean = true,
|
||||
val extensionRepoSettings: Boolean = true,
|
||||
val sourceSettings: Boolean = true,
|
||||
|
@ -23,6 +24,7 @@ data class BackupOptions(
|
|||
chapters,
|
||||
tracking,
|
||||
history,
|
||||
readEntries,
|
||||
appSettings,
|
||||
extensionRepoSettings,
|
||||
sourceSettings,
|
||||
|
@ -62,6 +64,12 @@ data class BackupOptions(
|
|||
getter = BackupOptions::categories,
|
||||
setter = { options, enabled -> options.copy(categories = enabled) },
|
||||
),
|
||||
Entry(
|
||||
label = MR.strings.non_library_settings,
|
||||
getter = BackupOptions::readEntries,
|
||||
setter = { options, enabled -> options.copy(readEntries = enabled) },
|
||||
enabled = { it.libraryEntries },
|
||||
),
|
||||
)
|
||||
|
||||
val settingsOptions = persistentListOf(
|
||||
|
@ -102,11 +110,12 @@ data class BackupOptions(
|
|||
chapters = array[2],
|
||||
tracking = array[3],
|
||||
history = array[4],
|
||||
appSettings = array[5],
|
||||
extensionRepoSettings = array[6],
|
||||
sourceSettings = array[7],
|
||||
privateSettings = array[8],
|
||||
extensions = array[9],
|
||||
readEntries = array[5],
|
||||
appSettings = array[6],
|
||||
extensionRepoSettings = array[7],
|
||||
sourceSettings = array[8],
|
||||
privateSettings = array[9],
|
||||
extensions = array[10],
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,10 @@ class AnimeRepositoryImpl(
|
|||
return handler.awaitList { animesQueries.getFavorites(AnimeMapper::mapAnime) }
|
||||
}
|
||||
|
||||
override suspend fun getWatchedAnimeNotInLibrary(): List<Anime> {
|
||||
return handler.awaitList { animesQueries.getWatchedAnimeNotInLibrary(AnimeMapper::mapAnime) }
|
||||
}
|
||||
|
||||
override suspend fun getLibraryAnime(): List<LibraryAnime> {
|
||||
return handler.awaitList { animelibViewQueries.animelib(AnimeMapper::mapLibraryAnime) }
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@ class MangaRepositoryImpl(
|
|||
return handler.awaitList { mangasQueries.getFavorites(MangaMapper::mapManga) }
|
||||
}
|
||||
|
||||
override suspend fun getReadMangaNotInLibrary(): List<Manga> {
|
||||
return handler.awaitList { mangasQueries.getReadMangaNotInLibrary(MangaMapper::mapManga) }
|
||||
}
|
||||
|
||||
override suspend fun getLibraryManga(): List<LibraryManga> {
|
||||
return handler.awaitList { libraryViewQueries.library(MangaMapper::mapLibraryManga) }
|
||||
}
|
||||
|
|
|
@ -78,6 +78,15 @@ SELECT *
|
|||
FROM mangas
|
||||
WHERE favorite = 1;
|
||||
|
||||
getReadMangaNotInLibrary:
|
||||
SELECT *
|
||||
FROM mangas
|
||||
WHERE favorite = 0 AND _id IN (
|
||||
SELECT DISTINCT chapters.manga_id
|
||||
FROM chapters
|
||||
WHERE read = 1 OR last_page_read != 0
|
||||
);
|
||||
|
||||
getAllManga:
|
||||
SELECT *
|
||||
FROM mangas;
|
||||
|
|
|
@ -77,6 +77,15 @@ SELECT *
|
|||
FROM animes
|
||||
WHERE favorite = 1;
|
||||
|
||||
getWatchedAnimeNotInLibrary:
|
||||
SELECT *
|
||||
FROM animes
|
||||
WHERE favorite = 0 AND _id IN (
|
||||
SELECT DISTINCT episodes.anime_id
|
||||
FROM episodes
|
||||
WHERE seen = 1 OR last_second_seen != 0
|
||||
);
|
||||
|
||||
getAllAnime:
|
||||
SELECT *
|
||||
FROM animes;
|
||||
|
|
|
@ -17,6 +17,8 @@ interface AnimeRepository {
|
|||
|
||||
suspend fun getAnimeFavorites(): List<Anime>
|
||||
|
||||
suspend fun getWatchedAnimeNotInLibrary(): List<Anime>
|
||||
|
||||
suspend fun getLibraryAnime(): List<LibraryAnime>
|
||||
|
||||
fun getLibraryAnimeAsFlow(): Flow<List<LibraryAnime>>
|
||||
|
|
|
@ -17,6 +17,8 @@ interface MangaRepository {
|
|||
|
||||
suspend fun getMangaFavorites(): List<Manga>
|
||||
|
||||
suspend fun getReadMangaNotInLibrary(): List<Manga>
|
||||
|
||||
suspend fun getLibraryManga(): List<LibraryManga>
|
||||
|
||||
fun getLibraryMangaAsFlow(): Flow<List<LibraryManga>>
|
||||
|
|
|
@ -490,6 +490,7 @@
|
|||
<string name="source_settings">Source settings</string>
|
||||
<string name="extensionRepo_settings">Extension repos</string>
|
||||
<string name="private_settings">Include sensitive settings (e.g., tracker login tokens)</string>
|
||||
<string name="non_library_settings">All read/watched entries</string>
|
||||
<string name="creating_backup">Creating backup</string>
|
||||
<string name="creating_backup_error">Backup failed</string>
|
||||
<string name="missing_storage_permission">Storage permissions not granted</string>
|
||||
|
|
Loading…
Reference in a new issue