mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 15:02:49 +01:00
refactor: write into cache instead of file.
Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
44946d1aec
commit
14bc550a24
@ -127,7 +127,7 @@ class SyncManager(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val backupUri = writeSyncDataToFile(context, newSyncData)
|
val backupUri = writeSyncDataToCache(context, newSyncData)
|
||||||
logcat(LogPriority.DEBUG) { "Got Backup Uri: $backupUri" }
|
logcat(LogPriority.DEBUG) { "Got Backup Uri: $backupUri" }
|
||||||
if (backupUri != null) {
|
if (backupUri != null) {
|
||||||
BackupRestoreJob.start(context, backupUri, sync = true)
|
BackupRestoreJob.start(context, backupUri, sync = true)
|
||||||
@ -137,15 +137,15 @@ class SyncManager(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun writeSyncDataToFile(context: Context, backup: Backup): Uri? {
|
private fun writeSyncDataToCache(context: Context, backup: Backup): Uri? {
|
||||||
val file = File(context.filesDir, "tachiyomi_sync_data.proto.gz")
|
val cacheFile = File(context.cacheDir, "tachiyomi_sync_data.proto.gz")
|
||||||
return try {
|
return try {
|
||||||
FileOutputStream(file).use { output ->
|
FileOutputStream(cacheFile).use { output ->
|
||||||
output.write(ProtoBuf.encodeToByteArray(BackupSerializer, backup))
|
output.write(ProtoBuf.encodeToByteArray(BackupSerializer, backup))
|
||||||
Uri.fromFile(file)
|
Uri.fromFile(cacheFile)
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
logcat(LogPriority.ERROR) { "Failed to write sync data locally" }
|
logcat(LogPriority.ERROR) { "Failed to write sync data to cache" }
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user