From 62b4d78e93200ce46fa82dc00e0aa7a3083ff2f0 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Sun, 3 May 2015 12:14:50 +0200 Subject: now possible to clone/create repository in a given external directory. *issues*: - not possible to switch between external/local directory without closing the app. (PasswordRepository is a singleton, has to be cleaned when a change is made) --- .../com/zeapo/pwdstore/utils/PasswordRepository.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/utils') diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index 6e7de7f1..9395fd68 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -5,8 +5,8 @@ import android.util.Log; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.RemoteConfig; @@ -49,11 +49,7 @@ public class PasswordRepository { } public static boolean isInitialized() { - return initialized; - } - - public static void setInitialized(boolean v) { - initialized = v; + return repository != null; } public static void createRepository(File localDir) throws Exception{ @@ -112,6 +108,7 @@ public class PasswordRepository { public static void closeRepository() { repository.close(); + repository = null; } public static ArrayList getFilesList(){ @@ -130,15 +127,6 @@ public class PasswordRepository { return repository.getWorkTree(); } - /** - * Gets a file from the working tree - * @param name the relative path of the file - * @return the file in the repository - */ - public static File getFile(String name) { - return new File(repository.getWorkTree() + "/" + name); - } - /** * Gets the .gpg files in a directory * @param path the directory path -- cgit v1.2.3