summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java19
2 files changed, 17 insertions, 6 deletions
diff --git a/app/build.gradle b/app/build.gradle
index e4e88753..08e282a5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,8 +9,8 @@ android {
applicationId "com.zeapo.pwdstore"
minSdkVersion 15
targetSdkVersion 23
- versionCode 70
- versionName "1.2.0.50"
+ versionCode 72
+ versionName "1.2.0.52"
}
compileOptions {
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
index a1ca9519..14b6ac59 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
@@ -475,7 +475,9 @@ public class GitActivity extends AppCompatActivity {
if (!saveConfiguration())
return;
- if (localDir.exists() && localDir.listFiles().length != 0) {
+ // Warn if non-empty folder unless it's a just-initialized store that has just a .git folder
+ if (localDir.exists() && localDir.listFiles().length != 0
+ && !(localDir.listFiles().length == 1 && localDir.listFiles()[0].getName().equals(".git"))) {
new AlertDialog.Builder(this).
setTitle(R.string.dialog_delete_title).
setMessage(getResources().getString(R.string.dialog_delete_msg) + " " + localDir.toString()).
@@ -493,13 +495,12 @@ public class GitActivity extends AppCompatActivity {
//This is what happens when jgit fails :(
//TODO Handle the diffent cases of exceptions
e.printStackTrace();
+ new AlertDialog.Builder(GitActivity.this).setMessage(e.getMessage()).show();
}
} catch (IOException e) {
//TODO Handle the exception correctly if we are unable to delete the directory...
e.printStackTrace();
- } catch (Exception e) {
- //This is what happens when jgit fails :(
- //TODO Handle the diffent cases of exceptions
+ new AlertDialog.Builder(GitActivity.this).setMessage(e.getMessage()).show();
}
dialog.cancel();
@@ -516,6 +517,15 @@ public class GitActivity extends AppCompatActivity {
show();
} else {
try {
+ // Silently delete & replace the lone .git folder if it exists
+ if (localDir.listFiles().length == 1 && localDir.listFiles()[0].getName().equals(".git")) {
+ try {
+ FileUtils.deleteDirectory(localDir);
+ } catch (IOException e) {
+ e.printStackTrace();
+ new AlertDialog.Builder(GitActivity.this).setMessage(e.getMessage()).show();
+ }
+ }
new CloneOperation(localDir, activity)
.setCommand(hostname)
.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
@@ -523,6 +533,7 @@ public class GitActivity extends AppCompatActivity {
//This is what happens when jgit fails :(
//TODO Handle the diffent cases of exceptions
e.printStackTrace();
+ new AlertDialog.Builder(this).setMessage(e.getMessage()).show();
}
}
}