File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
app/src/main/kotlin/com/d4rk/cleaner/app/clean/scanner/domain Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import java.io.File
12
12
class FileAnalyzer (
13
13
private val getDuplicatesUseCase : GetDuplicatesUseCase
14
14
) {
15
- fun computeGroupedFiles (
15
+ suspend fun computeGroupedFiles (
16
16
scannedFiles : List <File >,
17
17
emptyFolders : List <File >,
18
18
fileTypesData : FileTypesData ,
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import com.d4rk.cleaner.core.utils.extensions.partialMd5
6
6
import kotlinx.coroutines.async
7
7
import kotlinx.coroutines.awaitAll
8
8
import kotlinx.coroutines.coroutineScope
9
- import kotlinx.coroutines.runBlocking
10
9
import kotlinx.coroutines.withContext
11
10
import java.io.File
12
11
import java.util.concurrent.ConcurrentHashMap
@@ -17,14 +16,14 @@ class GetDuplicatesUseCase(
17
16
private val hashCache = ConcurrentHashMap <String , String >()
18
17
private val chunkSize = 100
19
18
20
- operator fun invoke (files : List <File >): List <List <FileEntry >> = runBlocking {
19
+ suspend operator fun invoke (files : List <File >): List <List <FileEntry >> {
21
20
val candidates = files.filter { it.isFile }
22
21
.groupBy { it.length() to it.lastModified() }
23
22
.values
24
23
.filter { it.size > 1 }
25
24
.flatten()
26
25
27
- if (candidates.isEmpty()) return @runBlocking emptyList()
26
+ if (candidates.isEmpty()) return emptyList()
28
27
29
28
val hashed = coroutineScope {
30
29
candidates.chunked(chunkSize).map { chunk ->
@@ -40,7 +39,7 @@ class GetDuplicatesUseCase(
40
39
}.awaitAll().flatten()
41
40
}
42
41
43
- hashed.groupBy({ it.first }, { it.second })
42
+ return hashed.groupBy({ it.first }, { it.second })
44
43
.values
45
44
.filter { it.size > 1 }
46
45
.map { group ->
You can’t perform that action at this time.
0 commit comments