@@ -58,19 +58,20 @@ import java.nio.file.Path
58
58
import java.nio.file.Paths
59
59
import javax.inject.Inject
60
60
import kotlin.io.path.ExperimentalPathApi
61
+ import kotlin.io.path.PathWalkOption
61
62
import kotlin.io.path.absolute
62
63
import kotlin.io.path.absolutePathString
63
64
import kotlin.io.path.createDirectories
64
65
import kotlin.io.path.deleteRecursively
65
66
import kotlin.io.path.exists
66
67
import kotlin.io.path.isDirectory
67
68
import kotlin.io.path.isRegularFile
68
- import kotlin.io.path.listDirectoryEntries
69
69
import kotlin.io.path.moveTo
70
70
import kotlin.io.path.name
71
71
import kotlin.io.path.nameWithoutExtension
72
72
import kotlin.io.path.pathString
73
73
import kotlin.io.path.relativeTo
74
+ import kotlin.io.path.walk
74
75
import kotlinx.coroutines.launch
75
76
import kotlinx.coroutines.withContext
76
77
import logcat.LogPriority.ERROR
@@ -79,6 +80,7 @@ import logcat.logcat
79
80
80
81
const val PASSWORD_FRAGMENT_TAG = " PasswordsList"
81
82
83
+ @OptIn(ExperimentalPathApi ::class )
82
84
@AndroidEntryPoint
83
85
class PasswordStore : BaseGitActivity () {
84
86
@@ -446,7 +448,8 @@ class PasswordStore : BaseGitActivity() {
446
448
fun deletePasswords (selectedItems : List <PasswordItem >) {
447
449
var size = 0
448
450
selectedItems.forEach {
449
- if (it.file.isRegularFile()) size++ else size + = it.file.listDirectoryEntries().size
451
+ if (it.file.isRegularFile()) size++
452
+ else size + = it.file.walk(PathWalkOption .INCLUDE_DIRECTORIES ).toSet().size
450
453
}
451
454
if (size == 0 ) {
452
455
selectedItems.map { item -> item.file.deleteRecursively() }
@@ -458,7 +461,7 @@ class PasswordStore : BaseGitActivity() {
458
461
.setPositiveButton(resources.getString(R .string.dialog_yes)) { _, _ ->
459
462
val filesToDelete = arrayListOf<Path >()
460
463
selectedItems.forEach { item ->
461
- if (item.file.isDirectory()) filesToDelete.addAll(item.file.listDirectoryEntries ())
464
+ if (item.file.isDirectory()) filesToDelete.addAll(item.file.walk ())
462
465
else filesToDelete.add(item.file)
463
466
}
464
467
selectedItems.map { item -> item.file.deleteRecursively() }
@@ -599,9 +602,7 @@ class PasswordStore : BaseGitActivity() {
599
602
// Recursively list all files (not directories) below `source`, then
600
603
// obtain the corresponding target file by resolving the relative path
601
604
// starting at the destination folder.
602
- source.listDirectoryEntries().associateWith {
603
- destinationFile.resolve(it.relativeTo(source))
604
- }
605
+ source.walk().associateWith { destinationFile.resolve(it.relativeTo(source)) }
605
606
} else {
606
607
mapOf (source to destinationFile)
607
608
}
0 commit comments