diff options
author | Marvin W <git@larma.de> | 2022-03-30 10:36:52 -0600 |
---|---|---|
committer | Marvin W <git@larma.de> | 2022-03-30 10:36:52 -0600 |
commit | 193bf38a790b2a124493c3b7ad591f826e0f773d (patch) | |
tree | 2568a9d2d4bad3f0c105a3fa23069a7cf1e56a72 /libdino/src/service | |
parent | 339d1d8f557e88ef6bb5812980b8988dc8fdf10d (diff) | |
download | dino-193bf38a790b2a124493c3b7ad591f826e0f773d.tar.gz dino-193bf38a790b2a124493c3b7ad591f826e0f773d.zip |
Allow cancellation of file transfers
Diffstat (limited to 'libdino/src/service')
-rw-r--r-- | libdino/src/service/file_manager.vala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala index a478695c..b82e0afb 100644 --- a/libdino/src/service/file_manager.vala +++ b/libdino/src/service/file_manager.vala @@ -246,7 +246,7 @@ public class FileManager : StreamInteractionModule, Object { File file = File.new_for_path(Path.build_filename(get_storage_dir(), filename)); OutputStream os = file.create(FileCreateFlags.REPLACE_DESTINATION); - yield os.splice_async(input_stream, OutputStreamSpliceFlags.CLOSE_SOURCE|OutputStreamSpliceFlags.CLOSE_TARGET); + yield os.splice_async(input_stream, OutputStreamSpliceFlags.CLOSE_SOURCE | OutputStreamSpliceFlags.CLOSE_TARGET, Priority.LOW, file_transfer.cancellable); file_transfer.path = file.get_basename(); file_transfer.input_stream = yield file.read_async(); @@ -292,14 +292,15 @@ public class FileManager : StreamInteractionModule, Object { if (is_sender_trustworthy(file_transfer, conversation)) { try { yield get_file_meta(file_provider, file_transfer, conversation, receive_data); - - if (file_transfer.size >= 0 && file_transfer.size < 5000000) { - yield download_file_internal(file_provider, file_transfer, conversation); - } } catch (Error e) { warning("Error downloading file: %s", e.message); file_transfer.state = FileTransfer.State.FAILED; } + if (file_transfer.size >= 0 && file_transfer.size < 5000000) { + download_file_internal.begin(file_provider, file_transfer, conversation, (_, res) => { + download_file_internal.end(res); + }); + } } conversation.last_active = file_transfer.time; |