From e3eb6b1c9c2b0ec156a5b9911b9d64b73082cf84 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 25 Mar 2023 11:27:58 +0530 Subject: fix: ensure repo dir is recreated after deletion --- .../java/app/passwordstore/ui/git/config/GitServerConfigActivity.kt | 5 ++++- .../main/java/app/passwordstore/ui/settings/RepositorySettings.kt | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/app/passwordstore/ui/git/config/GitServerConfigActivity.kt b/app/src/main/java/app/passwordstore/ui/git/config/GitServerConfigActivity.kt index 78f1aa2b..0fab992f 100644 --- a/app/src/main/java/app/passwordstore/ui/git/config/GitServerConfigActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/git/config/GitServerConfigActivity.kt @@ -242,7 +242,10 @@ class GitServerConfigActivity : BaseGitActivity() { message = getString(R.string.delete_directory_progress_text), length = Snackbar.LENGTH_INDEFINITE ) - withContext(Dispatchers.IO) { localDir.deleteRecursively() } + withContext(Dispatchers.IO) { + localDir.deleteRecursively() + localDir.mkdirs() + } snackbar.dismiss() launchGitOperation(GitOp.CLONE) .fold( diff --git a/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt b/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt index 8b478d63..8bd61f41 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt @@ -162,8 +162,11 @@ class RepositorySettings(private val activity: FragmentActivity) : SettingsProvi .setCancelable(false) .setPositiveButton(R.string.dialog_delete) { dialogInterface, _ -> runCatching { - PasswordRepository.getRepositoryDirectory().deleteRecursively() PasswordRepository.closeRepository() + PasswordRepository.getRepositoryDirectory().let { dir -> + dir.deleteRecursively() + dir.mkdirs() + } } .onFailure { it.message?.let { message -> activity.snackbar(message = message) } } -- cgit v1.2.3