aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-10-30 15:10:20 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2014-10-30 15:14:44 +0100
commit70175279993b60c2c06e0f3d7d7d1f8e4b914ad9 (patch)
treec3d4561a19038a94ffb8a07bc0262fcb6d38ae33 /OpenKeychain
parenta221464f38d70e54b5df31ca7a980de2fc2910b2 (diff)
downloadopen-keychain-70175279993b60c2c06e0f3d7d7d1f8e4b914ad9.tar.gz
open-keychain-70175279993b60c2c06e0f3d7d7d1f8e4b914ad9.tar.bz2
open-keychain-70175279993b60c2c06e0f3d7d7d1f8e4b914ad9.zip
forgot a thing for secret key export
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
index 9db9e700f..9b9c5043d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
@@ -458,30 +458,36 @@ public class ImportExportOperation extends BaseOperation {
// Create an output stream
ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream);
- String version = PgpHelper.getVersionForHeader(mContext);
- if (version != null) {
- arOutStream.setHeader("Version", version);
- }
+ try {
+ String version = PgpHelper.getVersionForHeader(mContext);
+ if (version != null) {
+ arOutStream.setHeader("Version", version);
+ }
- long keyId = cursor.getLong(0);
+ long keyId = cursor.getLong(0);
- log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
+ log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
- { // export public key part
- byte[] data = cursor.getBlob(1);
- arOutStream.write(data);
- arOutStream.close();
+ { // export public key part
+ byte[] data = cursor.getBlob(1);
+ arOutStream.write(data);
- okPublic += 1;
- }
+ okPublic += 1;
+ }
- // export secret key part
- if (exportSecret && cursor.getInt(3) > 0) {
- log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
- byte[] data = cursor.getBlob(2);
- arOutStream.write(data);
+ // export secret key part
+ if (exportSecret && cursor.getInt(3) > 0) {
+ log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
+ byte[] data = cursor.getBlob(2);
+ arOutStream.write(data);
- okSecret += 1;
+ okSecret += 1;
+ }
+ } finally {
+ // make sure this is closed
+ if (arOutStream != null) {
+ arOutStream.close();
+ }
}
updateProgress(progress++, numKeys);