From 97e98f880425e1b297a91af61f260e0f69775add Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 15 Apr 2014 06:03:53 +0200 Subject: [PATCH] Gdrive: fixed possible exception when listing files of root folder --- .../javafilestorage/GoogleDriveFileStorage.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java b/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java index 8573b666..98d7a5ef 100644 --- a/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java +++ b/src/java/JavaFileStorage/src/keepass2android/javafilestorage/GoogleDriveFileStorage.java @@ -181,7 +181,12 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase { if (!path.startsWith(getProtocolPrefix())) throw new InvalidPathException("Invalid path: "+path); String pathWithoutProtocol = path.substring(getProtocolPrefix().length()); - String accountNameEncoded = pathWithoutProtocol.substring(0, pathWithoutProtocol.indexOf("/")); + int slashPos = pathWithoutProtocol.indexOf("/"); + String accountNameEncoded; + if (slashPos < 0) + accountNameEncoded = pathWithoutProtocol; + else + accountNameEncoded = pathWithoutProtocol.substring(0, slashPos); return decode(accountNameEncoded); } @@ -190,7 +195,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase { //gdrive:// String displayName = getProtocolPrefix(); - //gdrive//me@google.com/ + //gdrive://me@google.com/ displayName += mAccount;