mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 15:09:17 +01:00
fix: decoding and encoding.
Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
205d34358c
commit
f02a9de4db
@ -137,7 +137,8 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
|
|||||||
return withContext(Dispatchers.IO) {
|
return withContext(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val gzipInputStream = GZIPInputStream(ByteArrayInputStream(outputStream.toByteArray()))
|
val gzipInputStream = GZIPInputStream(ByteArrayInputStream(outputStream.toByteArray()))
|
||||||
val syncData = json.decodeFromString<SyncData>(gzipInputStream.reader(Charsets.UTF_8).readText())
|
val jsonString = gzipInputStream.bufferedReader(Charsets.UTF_8).use { it.readText() }
|
||||||
|
val syncData = json.decodeFromString(SyncData.serializer(), jsonString)
|
||||||
logcat(LogPriority.DEBUG) { "JSON deserialized successfully" }
|
logcat(LogPriority.DEBUG) { "JSON deserialized successfully" }
|
||||||
syncData
|
syncData
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -157,10 +158,10 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
|
|||||||
val byteArrayOutputStream = ByteArrayOutputStream()
|
val byteArrayOutputStream = ByteArrayOutputStream()
|
||||||
|
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
val jsonData = json.encodeToString(syncData)
|
||||||
val gzipOutputStream = GZIPOutputStream(byteArrayOutputStream)
|
val gzipOutputStream = GZIPOutputStream(byteArrayOutputStream)
|
||||||
gzipOutputStream.writer(Charsets.UTF_8).use { writer ->
|
gzipOutputStream.write(jsonData.toByteArray(Charsets.UTF_8))
|
||||||
writer.write(json.encodeToString(syncData))
|
gzipOutputStream.close()
|
||||||
}
|
|
||||||
logcat(LogPriority.DEBUG) { "JSON serialized successfully" }
|
logcat(LogPriority.DEBUG) { "JSON serialized successfully" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user