aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain
diff options
context:
space:
mode:
authorDaniel Haß <mail@danielhass.de>2014-03-03 09:36:10 +0100
committerDaniel Haß <mail@danielhass.de>2014-03-03 09:36:10 +0100
commitf484122c353aa66dbc1a3a776163eaa28d70e4d5 (patch)
tree880c30561a22399987a6acdabb8c2ac0d6e2bf7c /OpenPGP-Keychain
parent9843bafafdcec1721b5715440011e5f7b72ac583 (diff)
downloadopen-keychain-f484122c353aa66dbc1a3a776163eaa28d70e4d5.tar.gz
open-keychain-f484122c353aa66dbc1a3a776163eaa28d70e4d5.tar.bz2
open-keychain-f484122c353aa66dbc1a3a776163eaa28d70e4d5.zip
Added exception for empty files
Diffstat (limited to 'OpenPGP-Keychain')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java
index 29e418db7..bc8e4d050 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java
@@ -33,7 +33,14 @@ import org.sufficientlysecure.keychain.util.PositionAwareInputStream;
import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
+import com.devspark.appmsg.AppMsg;
+
public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
+
+ public static class FileHasNoContent extends Exception {
+
+ }
+
Context mContext;
InputData mInputData;
@@ -92,6 +99,9 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
* @return
*/
private void generateListOfKeyrings(InputData inputData) {
+
+ boolean isEmpty = true;
+
PositionAwareInputStream progressIn = new PositionAwareInputStream(
inputData.getInputStream());
@@ -103,6 +113,7 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
// read all available blocks... (asc files can contain many blocks with BEGIN END)
while (bufferedInput.available() > 0) {
+ isEmpty = false;
InputStream in = PGPUtil.getDecoderStream(bufferedInput);
PGPObjectFactory objectFactory = new PGPObjectFactory(in);
@@ -120,7 +131,12 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
}
}
} catch (Exception e) {
- Log.e(Constants.TAG, "Exception on parsing key file!", e);
+
+ }
+
+ if(isEmpty) {
+ Log.e(Constants.TAG, "File has no content!", new FileHasNoContent());
+ entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(data, new FileHasNoContent());
}
}