mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 14:38:45 +03:00
Improve code about path
This commit is contained in:
parent
e069e196af
commit
a2225b3f76
2 changed files with 4 additions and 4 deletions
|
@ -32,17 +32,17 @@ internal class InitialSyncResponseParser @Inject constructor(private val moshi:
|
||||||
Timber.v("INIT_SYNC Sync file size is $syncResponseLength bytes")
|
Timber.v("INIT_SYNC Sync file size is $syncResponseLength bytes")
|
||||||
val shouldSplit = syncResponseLength >= syncStrategy.minSizeToSplit
|
val shouldSplit = syncResponseLength >= syncStrategy.minSizeToSplit
|
||||||
Timber.v("INIT_SYNC should split in several files: $shouldSplit")
|
Timber.v("INIT_SYNC should split in several files: $shouldSplit")
|
||||||
return getMoshi(syncStrategy, workingFile, shouldSplit)
|
return getMoshi(syncStrategy, workingFile.parentFile!!, shouldSplit)
|
||||||
.adapter(SyncResponse::class.java)
|
.adapter(SyncResponse::class.java)
|
||||||
.fromJson(workingFile.source().buffer())!!
|
.fromJson(workingFile.source().buffer())!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMoshi(syncStrategy: InitialSyncStrategy.Optimized, workingFile: File, shouldSplit: Boolean): Moshi {
|
private fun getMoshi(syncStrategy: InitialSyncStrategy.Optimized, workingDirectory: File, shouldSplit: Boolean): Moshi {
|
||||||
// If we don't have to split we'll rely on the already default moshi
|
// If we don't have to split we'll rely on the already default moshi
|
||||||
if (!shouldSplit) return moshi
|
if (!shouldSplit) return moshi
|
||||||
// Otherwise, we create a new adapter for handling Map of Lazy sync
|
// Otherwise, we create a new adapter for handling Map of Lazy sync
|
||||||
return moshi.newBuilder()
|
return moshi.newBuilder()
|
||||||
.add(SplitLazyRoomSyncJsonAdapter(workingFile, syncStrategy))
|
.add(SplitLazyRoomSyncJsonAdapter(workingDirectory, syncStrategy))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ internal class SplitLazyRoomSyncJsonAdapter(
|
||||||
|
|
||||||
private fun createFile(): File {
|
private fun createFile(): File {
|
||||||
val index = atomicInteger.getAndIncrement()
|
val index = atomicInteger.getAndIncrement()
|
||||||
return File(workingDirectory.parentFile, "room_$index.json")
|
return File(workingDirectory, "room_$index.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
@FromJson
|
@FromJson
|
||||||
|
|
Loading…
Reference in a new issue