aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
Diffstat (limited to 'libdino')
-rw-r--r--libdino/src/service/file_manager.vala12
-rw-r--r--libdino/src/service/jingle_file_transfers.vala2
2 files changed, 8 insertions, 6 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 2a665e1e..fa3042dd 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -152,6 +152,10 @@ public class FileManager : StreamInteractionModule, Object {
// Update current download progress in the FileTransfer
LimitInputStream? limit_stream = file_transfer.input_stream as LimitInputStream;
+ if (limit_stream == null) {
+ limit_stream = new LimitInputStream(file_transfer.input_stream, file_meta.size);
+ file_transfer.input_stream = limit_stream;
+ }
if (limit_stream != null) {
limit_stream.bind_property("retrieved-bytes", file_transfer, "transferred-bytes", BindingFlags.SYNC_CREATE);
}
@@ -267,9 +271,6 @@ public class FileManager : StreamInteractionModule, Object {
FileMeta file_meta = yield get_file_meta(file_provider, file_transfer, conversation, receive_data);
-
- InputStream? input_stream = null;
-
// Download and decrypt file
file_transfer.state = FileTransfer.State.IN_PROGRESS;
@@ -277,13 +278,14 @@ public class FileManager : StreamInteractionModule, Object {
file_meta = file_decryptor.prepare_download_file(conversation, file_transfer, receive_data, file_meta);
}
- input_stream = yield file_provider.download(file_transfer, receive_data, file_meta);
+ InputStream download_input_stream = yield file_provider.download(file_transfer, receive_data, file_meta);
+ InputStream input_stream = download_input_stream;
if (file_decryptor != null) {
input_stream = yield file_decryptor.decrypt_file(input_stream, conversation, file_transfer, receive_data);
}
// Update current download progress in the FileTransfer
- LimitInputStream? limit_stream = input_stream as LimitInputStream;
+ LimitInputStream? limit_stream = download_input_stream as LimitInputStream;
if (limit_stream != null) {
limit_stream.bind_property("retrieved-bytes", file_transfer, "transferred-bytes", BindingFlags.SYNC_CREATE);
}
diff --git a/libdino/src/service/jingle_file_transfers.vala b/libdino/src/service/jingle_file_transfers.vala
index e0d3fce1..9e9d7ec8 100644
--- a/libdino/src/service/jingle_file_transfers.vala
+++ b/libdino/src/service/jingle_file_transfers.vala
@@ -103,7 +103,7 @@ public class JingleFileProvider : FileProvider, Object {
throw new IOError.FAILED("Transfer data not available anymore");
}
yield jingle_file_transfer.accept(stream);
- return jingle_file_transfer.stream;
+ return new LimitInputStream(jingle_file_transfer.stream, file_meta.size);
}
public int get_id() {