mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore(backup/creator): Split error log
This commit is contained in:
parent
532e1faae4
commit
6d668ae086
2 changed files with 6 additions and 9 deletions
|
@ -9,5 +9,5 @@
|
||||||
|
|
||||||
## Other ?? Technical stuff, what happened behind the scene
|
## Other ?? Technical stuff, what happened behind the scene
|
||||||
-->
|
-->
|
||||||
## Fixes
|
## Other
|
||||||
- Fixed more NPE crashes
|
- Separate backup error log when destination is null or not a file
|
||||||
|
|
|
@ -18,9 +18,7 @@ import okio.gzip
|
||||||
import okio.sink
|
import okio.sink
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
|
||||||
import yokai.domain.backup.BackupPreferences
|
import yokai.domain.backup.BackupPreferences
|
||||||
import yokai.domain.storage.StorageManager
|
|
||||||
import yokai.i18n.MR
|
import yokai.i18n.MR
|
||||||
import yokai.util.lang.getString
|
import yokai.util.lang.getString
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
@ -37,7 +35,6 @@ class BackupCreator(
|
||||||
val parser = ProtoBuf
|
val parser = ProtoBuf
|
||||||
private val db: DatabaseHelper = Injekt.get()
|
private val db: DatabaseHelper = Injekt.get()
|
||||||
private val backupPreferences: BackupPreferences = Injekt.get()
|
private val backupPreferences: BackupPreferences = Injekt.get()
|
||||||
private val storageManager: StorageManager by injectLazy()
|
|
||||||
|
|
||||||
@Suppress("RedundantSuspendModifier")
|
@Suppress("RedundantSuspendModifier")
|
||||||
private suspend fun getDatabaseManga(includeReadManga: Boolean) = db.inTransactionReturn {
|
private suspend fun getDatabaseManga(includeReadManga: Boolean) = db.inTransactionReturn {
|
||||||
|
@ -60,7 +57,7 @@ class BackupCreator(
|
||||||
try {
|
try {
|
||||||
file = if (isAutoBackup) {
|
file = if (isAutoBackup) {
|
||||||
// Get dir of file and create
|
// Get dir of file and create
|
||||||
val dir = storageManager.getAutomaticBackupsDirectory()
|
val dir = UniFile.fromUri(context, uri)
|
||||||
|
|
||||||
// Delete older backups
|
// Delete older backups
|
||||||
val numberOfBackups = backupPreferences.numberOfBackups().get()
|
val numberOfBackups = backupPreferences.numberOfBackups().get()
|
||||||
|
@ -74,10 +71,10 @@ class BackupCreator(
|
||||||
dir?.createFile(Backup.getBackupFilename())
|
dir?.createFile(Backup.getBackupFilename())
|
||||||
} else {
|
} else {
|
||||||
UniFile.fromUri(context, uri)
|
UniFile.fromUri(context, uri)
|
||||||
}
|
} ?: throw IllegalStateException("Unable to retrieve backup destination")
|
||||||
|
|
||||||
if (file == null || !file.isFile) {
|
if (!file.isFile) {
|
||||||
throw IllegalStateException("Failed to get handle on file")
|
throw IllegalStateException("Invalid backup destination")
|
||||||
}
|
}
|
||||||
|
|
||||||
val backupManga = mangaBackupCreator(getDatabaseManga(options.readManga), options)
|
val backupManga = mangaBackupCreator(getDatabaseManga(options.readManga), options)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue