mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 13:21:49 +01:00
Minor updates
This commit is contained in:
parent
87f3d4bd05
commit
3f0db60a99
@ -108,7 +108,7 @@ object SettingsBackupScreen : SearchableSettings {
|
|||||||
showCreateDialog = false
|
showCreateDialog = false
|
||||||
flag = it
|
flag = it
|
||||||
try {
|
try {
|
||||||
chooseBackupDir.launch(Backup.getBackupFilename())
|
chooseBackupDir.launch(Backup.getFilename())
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
flag = 0
|
flag = 0
|
||||||
context.toast(R.string.file_picker_error)
|
context.toast(R.string.file_picker_error)
|
||||||
|
@ -93,15 +93,14 @@ class BackupManager(
|
|||||||
|
|
||||||
// Delete older backups
|
// Delete older backups
|
||||||
val numberOfBackups = backupPreferences.numberOfBackups().get()
|
val numberOfBackups = backupPreferences.numberOfBackups().get()
|
||||||
val backupRegex = Regex("""tachiyomi_\d+-\d+-\d+_\d+-\d+.proto.gz""")
|
dir.listFiles { _, filename -> Backup.filenameRegex.matches(filename) }
|
||||||
dir.listFiles { _, filename -> backupRegex.matches(filename) }
|
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
.sortedByDescending { it.name }
|
.sortedByDescending { it.name }
|
||||||
.drop(numberOfBackups - 1)
|
.drop(numberOfBackups - 1)
|
||||||
.forEach { it.delete() }
|
.forEach { it.delete() }
|
||||||
|
|
||||||
// Create new file to place backup
|
// Create new file to place backup
|
||||||
dir.createFile(Backup.getBackupFilename())
|
dir.createFile(Backup.getFilename())
|
||||||
} else {
|
} else {
|
||||||
UniFile.fromUri(context, uri)
|
UniFile.fromUri(context, uri)
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,9 @@ data class Backup(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getBackupFilename(): String {
|
val filenameRegex = """tachiyomi_\d+-\d+-\d+_\d+-\d+.proto.gz""".toRegex()
|
||||||
|
|
||||||
|
fun getFilename(): String {
|
||||||
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm", Locale.getDefault()).format(Date())
|
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm", Locale.getDefault()).format(Date())
|
||||||
return "tachiyomi_$date.proto.gz"
|
return "tachiyomi_$date.proto.gz"
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,11 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
|||||||
import eu.kanade.tachiyomi.util.storage.saveTo
|
import eu.kanade.tachiyomi.util.storage.saveTo
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import logcat.LogPriority
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
import okio.sink
|
import okio.sink
|
||||||
|
import tachiyomi.core.util.system.logcat
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -97,6 +99,7 @@ class ChapterCache(private val context: Context) {
|
|||||||
editor.commit()
|
editor.commit()
|
||||||
editor.abortUnlessCommitted()
|
editor.abortUnlessCommitted()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
logcat(LogPriority.WARN, e) { "Failed to put page list to cache" }
|
||||||
// Ignore.
|
// Ignore.
|
||||||
} finally {
|
} finally {
|
||||||
editor?.abortUnlessCommitted()
|
editor?.abortUnlessCommitted()
|
||||||
@ -174,7 +177,7 @@ class ChapterCache(private val context: Context) {
|
|||||||
* @return status of deletion for the file.
|
* @return status of deletion for the file.
|
||||||
*/
|
*/
|
||||||
private fun removeFileFromCache(file: String): Boolean {
|
private fun removeFileFromCache(file: String): Boolean {
|
||||||
// Make sure we don't delete the journal file (keeps track of cache).
|
// Make sure we don't delete the journal file (keeps track of cache)
|
||||||
if (file == "journal" || file.startsWith("journal.")) {
|
if (file == "journal" || file.startsWith("journal.")) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -182,9 +185,10 @@ class ChapterCache(private val context: Context) {
|
|||||||
return try {
|
return try {
|
||||||
// Remove the extension from the file to get the key of the cache
|
// Remove the extension from the file to get the key of the cache
|
||||||
val key = file.substringBeforeLast(".")
|
val key = file.substringBeforeLast(".")
|
||||||
// Remove file from cache.
|
// Remove file from cache
|
||||||
diskCache.remove(key)
|
diskCache.remove(key)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
logcat(LogPriority.WARN, e) { "Failed to remove file from cache" }
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ interface Source {
|
|||||||
/**
|
/**
|
||||||
* Get the updated details for a manga.
|
* Get the updated details for a manga.
|
||||||
*
|
*
|
||||||
|
* @since extensions-lib 1.4
|
||||||
* @param manga the manga to update.
|
* @param manga the manga to update.
|
||||||
|
* @return the updated manga.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
suspend fun getMangaDetails(manga: SManga): SManga {
|
suspend fun getMangaDetails(manga: SManga): SManga {
|
||||||
@ -37,7 +39,9 @@ interface Source {
|
|||||||
/**
|
/**
|
||||||
* Get all the available chapters for a manga.
|
* Get all the available chapters for a manga.
|
||||||
*
|
*
|
||||||
|
* @since extensions-lib 1.4
|
||||||
* @param manga the manga to update.
|
* @param manga the manga to update.
|
||||||
|
* @return the chapters for the manga.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
suspend fun getChapterList(manga: SManga): List<SChapter> {
|
suspend fun getChapterList(manga: SManga): List<SChapter> {
|
||||||
@ -48,7 +52,9 @@ interface Source {
|
|||||||
* Get the list of pages a chapter has. Pages should be returned
|
* Get the list of pages a chapter has. Pages should be returned
|
||||||
* in the expected order; the index is ignored.
|
* in the expected order; the index is ignored.
|
||||||
*
|
*
|
||||||
|
* @since extensions-lib 1.4
|
||||||
* @param chapter the chapter.
|
* @param chapter the chapter.
|
||||||
|
* @return the pages for the chapter.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
suspend fun getPageList(chapter: SChapter): List<Page> {
|
suspend fun getPageList(chapter: SChapter): List<Page> {
|
||||||
|
Loading…
Reference in New Issue
Block a user