From 3d615d10dd93cc9633ef264f9f8121b8fff28ea4 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 18 Nov 2024 17:21:58 +0000 Subject: [PATCH] Calculate hash tree for file uploads --- src/views/Drive.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/views/Drive.vue b/src/views/Drive.vue index f5b5e868..bbe4039d 100644 --- a/src/views/Drive.vue +++ b/src/views/Drive.vue @@ -2153,13 +2153,16 @@ module.exports = { } let reader = new browserio.JSFileReader(file); let java_reader = new peergos.shared.user.fs.BrowserFileReader(reader); - let fup = new peergos.shared.user.fs.FileWrapper.FileUploadProperties(file.name, {get_0: () => java_reader}, - (file.size - (file.size % Math.pow(2, 32))) / Math.pow(2, 32), file.size, java.util.Optional.empty(), java.util.Optional.empty(), false, - overwriteExisting ? true : false, updateProgressBar); - - let fileUploadList = uploadParams.fileUploadProperties[foundDirectoryIndex]; - fileUploadList.push(fup); - future.complete(true); + peergos.shared.user.fs.HashTree.build(java_reader, (file.size - (file.size % Math.pow(2, 32))) / Math.pow(2, 32), + file.size, this.context.crypto.hasher).thenApply(function(hashtree) { + let fup = new peergos.shared.user.fs.FileWrapper.FileUploadProperties(file.name, {get_0: () => java_reader}, + (file.size - (file.size % Math.pow(2, 32))) / Math.pow(2, 32), file.size, java.util.Optional.empty(), java.util.Optional.of(hashtree), false, + overwriteExisting ? true : false, updateProgressBar); + + let fileUploadList = uploadParams.fileUploadProperties[foundDirectoryIndex]; + fileUploadList.push(fup); + future.complete(true); + }).exceptionally(function(t){future.completeExceptionally(t)}) }, addUploadProgressMessage: function(uploadParams, title, subtitle, directory, finalCall) { let that = this;