Skip to content

Commit

Permalink
wip: oops
Browse files Browse the repository at this point in the history
  • Loading branch information
Caio99BR committed Jun 25, 2024
1 parent 11ea089 commit 161426c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
return false
}

val inputData = workDataOf(
KEY_CATEGORY to category?.id,
)

val syncPreferences: SyncPreferences = Injekt.get()

// Always sync the data before library update if syncing is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import eu.kanade.tachiyomi.data.backup.create.BackupOptions
import eu.kanade.tachiyomi.data.backup.models.Backup
import eu.kanade.tachiyomi.data.backup.models.BackupChapter
import eu.kanade.tachiyomi.data.backup.models.BackupManga
import eu.kanade.tachiyomi.data.backup.models.BackupSerializer
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
import eu.kanade.tachiyomi.data.backup.restore.RestoreOptions
import eu.kanade.tachiyomi.data.backup.restore.restorers.MangaRestorer
Expand Down Expand Up @@ -202,7 +201,7 @@ class SyncManager(
val cacheFile = File(context.cacheDir, "tachiyomi_sync_data.proto.gz")
return try {
cacheFile.outputStream().use { output ->
output.write(ProtoBuf.encodeToByteArray(BackupSerializer, backup))
output.write(parser.encodeToByteArray(Backup.Serializer(), backup))
Uri.fromFile(cacheFile)
}
} catch (e: IOException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.data.sync.service
import android.content.Context
import eu.kanade.domain.sync.SyncPreferences
import eu.kanade.tachiyomi.data.backup.models.Backup
import eu.kanade.tachiyomi.data.backup.models.BackupSerializer
import eu.kanade.tachiyomi.data.sync.SyncNotifier
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.PUT
Expand Down Expand Up @@ -104,7 +103,7 @@ class SyncYomiSyncService(
}

return try {
val backup = protoBuf.decodeFromByteArray(BackupSerializer, byteArray)
val backup = parser.decodeFromByteArray(Backup.Serializer(), byteArray)
return Pair(SyncData(backup = backup), newETag)
} catch (_: SerializationException) {
logcat(LogPriority.INFO) {
Expand Down Expand Up @@ -147,7 +146,7 @@ class SyncYomiSyncService(
.writeTimeout(timeout, TimeUnit.SECONDS)
.build()

val byteArray = protoBuf.encodeToByteArray(BackupSerializer, backup)
val byteArray = parser.encodeToByteArray(Backup.Serializer(), backup)
if (byteArray.isEmpty()) {
throw IllegalStateException(context.stringResource(MR.strings.empty_backup_error))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ import logcat.logcat
inline fun Any.logcat(
priority: LogPriority = LogPriority.DEBUG,
throwable: Throwable? = null,
tag: String? = null,
message: () -> String = { "" },
) = logcat(priority = priority) {
var msg = message()
val logMessage = StringBuilder()

if (!tag.isNullOrEmpty()) {
logMessage.append("[$tag] ")
}

val msg = message()
logMessage.append(msg)

if (throwable != null) {
if (msg.isNotBlank()) msg += "\n"
msg += throwable.asLog()
if (msg.isNotBlank()) logMessage.append("\n")
logMessage.append(throwable.asLog())
}
msg

logMessage.toString()
}

0 comments on commit 161426c

Please sign in to comment.