summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Henneke <FabianHenneke@users.noreply.github.com>2020-03-26 19:08:01 +0100
committerGitHub <noreply@github.com>2020-03-26 19:08:01 +0100
commitde4cc638609da49c55766ea8cf3428a637badb7f (patch)
tree75d195971cf3982040ec5cc1e91862f545ea4420
parenta736dcc255b768f4275a200990943ab2c3567d0a (diff)
Fix deletion of individual password files (#668)
Commit fde8137b (#659) introduced a regression that results in Password Store crashing when the user tries to delete a single password file as opposed to a directory. The root cause is a call of FileUtils.listFiles() on the selected item, which only works for directories. The fix is to work with a list consisting only of the selected item if it happens to be a file.
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
index 008db7af..9ee28f09 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
@@ -499,7 +499,11 @@ class PasswordStore : AppCompatActivity() {
MaterialAlertDialogBuilder(this)
.setMessage(resources.getString(R.string.delete_dialog_text, item.longName))
.setPositiveButton(resources.getString(R.string.dialog_yes)) { _, _ ->
- val filesToDelete = FileUtils.listFiles(item.file, null, true)
+ val filesToDelete = if (item.file.isDirectory) {
+ FileUtils.listFiles(item.file, null, true)
+ } else {
+ listOf(item.file)
+ }
AutofillMatcher.updateMatches(applicationContext, delete = filesToDelete)
item.file.deleteRecursively()
adapter.remove(position)