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.
This commit is contained in:
Fabian Henneke 2020-03-26 19:08:01 +01:00 committed by GitHub
parent a736dcc255
commit de4cc63860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -499,7 +499,11 @@ class PasswordStore : AppCompatActivity() {
MaterialAlertDialogBuilder(this) MaterialAlertDialogBuilder(this)
.setMessage(resources.getString(R.string.delete_dialog_text, item.longName)) .setMessage(resources.getString(R.string.delete_dialog_text, item.longName))
.setPositiveButton(resources.getString(R.string.dialog_yes)) { _, _ -> .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) AutofillMatcher.updateMatches(applicationContext, delete = filesToDelete)
item.file.deleteRecursively() item.file.deleteRecursively()
adapter.remove(position) adapter.remove(position)