From 736522737f4dae39af126353abfe26903b2c82ea Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 13 Feb 2019 21:50:15 +0100 Subject: Make file read/write async --- plugins/http-files/src/file_provider.vala | 4 ++-- plugins/omemo/src/file_provider.vala | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala index 553068cc..80f99fa6 100644 --- a/plugins/http-files/src/file_provider.vala +++ b/plugins/http-files/src/file_provider.vala @@ -114,10 +114,10 @@ public class FileProvider : Dino.FileProvider, Object { } OutputStream os = file.create(FileCreateFlags.REPLACE_DESTINATION); - os.splice(file_transfer.input_stream, 0); + yield os.splice_async(file_transfer.input_stream, 0); os.close(); file_transfer.path = file.get_basename(); - file_transfer.input_stream = file.read(); + file_transfer.input_stream = yield file.read_async(); file_transfer.state = FileTransfer.State.COMPLETE; } catch (Error e) { diff --git a/plugins/omemo/src/file_provider.vala b/plugins/omemo/src/file_provider.vala index 49b42e92..bda73bfb 100644 --- a/plugins/omemo/src/file_provider.vala +++ b/plugins/omemo/src/file_provider.vala @@ -106,14 +106,14 @@ public class FileProvider : Dino.FileProvider, Object { var session = new Soup.Session(); Soup.Request request = session.request(url); - file_transfer.input_stream = decrypt_file(yield request.send_async(null), url_body); + file_transfer.input_stream = yield decrypt_file(yield request.send_async(null), url_body); file_transfer.encryption = Encryption.OMEMO; OutputStream os = file.create(FileCreateFlags.REPLACE_DESTINATION); - os.splice(file_transfer.input_stream, 0); + yield os.splice_async(file_transfer.input_stream, 0); os.close(); file_transfer.path = file.get_basename(); - file_transfer.input_stream = file.read(); + file_transfer.input_stream = yield file.read_async(); file_transfer.state = FileTransfer.State.COMPLETE; } catch (Error e) { @@ -121,7 +121,7 @@ public class FileProvider : Dino.FileProvider, Object { } } - public InputStream? decrypt_file(InputStream input_stream, string url) { + public async InputStream? decrypt_file(InputStream input_stream, string url) { // Decode IV and key MatchInfo match_info; this.url_regex.match(url, 0, out match_info); @@ -140,7 +140,7 @@ public class FileProvider : Dino.FileProvider, Object { Array data = new Array(false, true, 0); size_t len = -1; do { - len = input_stream.read(buf); + len = yield input_stream.read_async(buf); data.append_vals(buf, (uint) len); } while(len > 0); -- cgit v1.2.3-70-g09d2