diff options
Diffstat (limited to 'plugins/openpgp/src/in_file_processor.vala')
-rw-r--r-- | plugins/openpgp/src/in_file_processor.vala | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/plugins/openpgp/src/in_file_processor.vala b/plugins/openpgp/src/in_file_processor.vala index 2a06bbdf..61baa37e 100644 --- a/plugins/openpgp/src/in_file_processor.vala +++ b/plugins/openpgp/src/in_file_processor.vala @@ -8,19 +8,23 @@ public class InFileProcessor : IncommingFileProcessor, Object { } public void process(FileTransfer file_transfer) { - uint8[] buf = new uint8[256]; - Array<uint8> data = new Array<uint8>(false, true, 0); - size_t len = -1; - do { - len = file_transfer.input_stream.read(buf); - data.append_vals(buf, (uint) len); - } while(len > 0); + try { + uint8[] buf = new uint8[256]; + Array<uint8> data = new Array<uint8>(false, true, 0); + size_t len = -1; + do { + len = file_transfer.input_stream.read(buf); + data.append_vals(buf, (uint) len); + } while(len > 0); - uint8[] clear_data = GPGHelper.decrypt_data(data.data); - file_transfer.input_stream = new MemoryInputStream.from_data(clear_data, GLib.free); - file_transfer.encryption = Encryption.PGP; - if (file_transfer.file_name.has_suffix(".pgp")) { - file_transfer.file_name = file_transfer.file_name.substring(0, file_transfer.file_name.length - 4); + uint8[] clear_data = GPGHelper.decrypt_data(data.data); + file_transfer.input_stream = new MemoryInputStream.from_data(clear_data, GLib.free); + file_transfer.encryption = Encryption.PGP; + if (file_transfer.file_name.has_suffix(".pgp")) { + file_transfer.file_name = file_transfer.file_name.substring(0, file_transfer.file_name.length - 4); + } + } catch (Error e) { + file_transfer.state = FileTransfer.State.FAILED; } } } |