Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit d11b84e

Browse files
author
vadim
committed
fix: suspend method in non-io context
1 parent a336a14 commit d11b84e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app-core/src/main/java/com/codee/app/core/plugins/files/EmptyStorageElement.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package com.codee.app.core.plugins.files
22

3+
import kotlinx.coroutines.Dispatchers
4+
import kotlinx.coroutines.withContext
35
import java.io.File
46
import com.codee.app.plugins.api.files.EmptyStorageElement as IEmptyStorageElement
57

68
class EmptyStorageElement(private val origin: File, private val rootDirectory: File) :
79
IEmptyStorageElement {
8-
override suspend fun mkdir(): ChildDirectoryStorageElement {
10+
override suspend fun mkdir(): ChildDirectoryStorageElement = withContext(Dispatchers.IO) {
911
origin.mkdir()
10-
return ChildDirectoryStorageElement(origin, rootDirectory)
12+
return@withContext ChildDirectoryStorageElement(origin, rootDirectory)
1113
}
1214

13-
override suspend fun createNewFile(): FileStorageElement {
15+
override suspend fun createNewFile(): FileStorageElement = withContext(Dispatchers.IO) {
1416
origin.createNewFile()
15-
return FileStorageElement(origin, rootDirectory)
17+
return@withContext FileStorageElement(origin, rootDirectory)
1618
}
1719

1820
override val name: String

0 commit comments

Comments
 (0)