From de4cc638609da49c55766ea8cf3428a637badb7f Mon Sep 17 00:00:00 2001 From: Fabian Henneke Date: Thu, 26 Mar 2020 19:08:01 +0100 Subject: 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. --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/src/main/java') 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) -- cgit v1.2.3