aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2018-11-27 18:28:28 +0100
committerfiaxh <git@lightrise.org>2018-11-27 18:28:28 +0100
commit7c1d580e174ff31a55677e976d87284868bd99c6 (patch)
tree986a66282848c06390ce1e9f0e9494965aa6a1d3 /libdino/src/service
parent141db9e40a3a81cfa3ad3587dc47f69c541d0fde (diff)
downloaddino-7c1d580e174ff31a55677e976d87284868bd99c6.tar.gz
dino-7c1d580e174ff31a55677e976d87284868bd99c6.zip
Fix aesgcm http file up/download bugs
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/file_manager.vala25
1 files changed, 16 insertions, 9 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 8e76af30..861c51da 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -143,17 +143,23 @@ public class FileManager : StreamInteractionModule, Object {
private async void handle_incomming_file(FileProvider file_provider, FileTransfer file_transfer, Conversation conversation) {
if (!is_sender_trustworthy(file_transfer, conversation)) return;
- string filename = Random.next_int().to_string("%x") + "_" + file_transfer.file_name;
- File file = File.new_for_path(Path.build_filename(get_storage_dir(), filename));
- yield file_provider.download(file_transfer, file);
+ if (file_transfer.size == -1) {
+ file_provider.get_meta_info(file_transfer);
+ }
- try {
- FileInfo file_info = file_transfer.get_file().query_info("*", FileQueryInfoFlags.NONE);
- file_transfer.mime_type = file_info.get_content_type();
- } catch (Error e) { }
+ if (file_transfer.size >= 0 && file_transfer.size < 5000000) {
+ string filename = Random.next_int().to_string("%x") + "_" + file_transfer.file_name;
+ File file = File.new_for_path(Path.build_filename(get_storage_dir(), filename));
+ yield file_provider.download(file_transfer, file);
- file_transfer.persist(db);
- received_file(file_transfer, conversation);
+ try {
+ FileInfo file_info = file_transfer.get_file().query_info("*", FileQueryInfoFlags.NONE);
+ file_transfer.mime_type = file_info.get_content_type();
+ } catch (Error e) { }
+
+ file_transfer.persist(db);
+ received_file(file_transfer, conversation);
+ }
}
private void save_file(FileTransfer file_transfer) {
@@ -175,6 +181,7 @@ public class FileManager : StreamInteractionModule, Object {
public interface FileProvider : Object {
public signal void file_incoming(FileTransfer file_transfer, Conversation conversation);
+ public abstract async void get_meta_info(FileTransfer file_transfer);
public abstract async void download(FileTransfer file_transfer, File file);
}