summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-03-25 11:27:58 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-03-25 11:30:19 +0530
commite3eb6b1c9c2b0ec156a5b9911b9d64b73082cf84 (patch)
tree815ee64b3fb78d44a3adf9bf755af4010fcc662e
parent3761de87833d9f5c4f90320f3f5196135ff64632 (diff)
fix: ensure repo dir is recreated after deletion
-rw-r--r--app/src/main/java/app/passwordstore/ui/git/config/GitServerConfigActivity.kt5
-rw-r--r--app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt5
2 files changed, 8 insertions, 2 deletions
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) } }