From a2225b3f760ae56702719ec44a48f1e39de3db23 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 8 Feb 2021 18:56:41 +0100 Subject: [PATCH] Improve code about path --- .../session/sync/parsing/InitialSyncResponseParser.kt | 6 +++--- .../session/sync/parsing/LazyRoomSyncJsonAdapters.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt index 6145793178..ae7b2a4468 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt @@ -32,17 +32,17 @@ internal class InitialSyncResponseParser @Inject constructor(private val moshi: Timber.v("INIT_SYNC Sync file size is $syncResponseLength bytes") val shouldSplit = syncResponseLength >= syncStrategy.minSizeToSplit 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) .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 (!shouldSplit) return moshi // Otherwise, we create a new adapter for handling Map of Lazy sync return moshi.newBuilder() - .add(SplitLazyRoomSyncJsonAdapter(workingFile, syncStrategy)) + .add(SplitLazyRoomSyncJsonAdapter(workingDirectory, syncStrategy)) .build() } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/LazyRoomSyncJsonAdapters.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/LazyRoomSyncJsonAdapters.kt index 2d25d0bc2e..951fdf86aa 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/LazyRoomSyncJsonAdapters.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/LazyRoomSyncJsonAdapters.kt @@ -52,7 +52,7 @@ internal class SplitLazyRoomSyncJsonAdapter( private fun createFile(): File { val index = atomicInteger.getAndIncrement() - return File(workingDirectory.parentFile, "room_$index.json") + return File(workingDirectory, "room_$index.json") } @FromJson