GitServerConfigActivity: fix repository clone flow

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-04-12 22:02:13 +05:30
parent 2b95b69650
commit 9e0cc72746
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -93,6 +93,8 @@ class GitServerConfigActivity : BaseGitActivity() {
}
binding.saveButton.setOnClickListener {
if (isClone && PasswordRepository.getRepository(null) == null)
PasswordRepository.initialize(this)
if (updateHostname()) {
settings.edit(true) {
putString("git_remote_protocol", protocol.toString())
@ -104,12 +106,11 @@ class GitServerConfigActivity : BaseGitActivity() {
}
if (!isClone)
Snackbar.make(binding.root, getString(R.string.git_server_config_save_success), Snackbar.LENGTH_SHORT).show()
else
cloneRepository()
} else {
Snackbar.make(binding.root, getString(R.string.git_server_config_save_failure), Snackbar.LENGTH_LONG).show()
}
if (isClone) {
cloneRepository()
}
}
}
@ -117,9 +118,6 @@ class GitServerConfigActivity : BaseGitActivity() {
* Clones the repository, the directory exists, deletes it
*/
private fun cloneRepository() {
if (PasswordRepository.getRepository(null) == null) {
PasswordRepository.initialize(this)
}
val localDir = requireNotNull(PasswordRepository.getRepositoryDirectory(this))
// Warn if non-empty folder unless it's a just-initialized store that has just a .git folder