From b86f8e3f267f9ea001185d21c24486c7a242fd34 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 12 Oct 2017 17:33:22 +0200 Subject: [PATCH] Fix uloaded files not moved to the correct folder in drive --- www/common/common-file.js | 4 ++++ www/common/sframe-common-file.js | 1 - www/drive/inner.js | 28 ++++++++-------------------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/www/common/common-file.js b/www/common/common-file.js index 6b1f33505..97705e556 100644 --- a/www/common/common-file.js +++ b/www/common/common-file.js @@ -28,6 +28,9 @@ define([ var u8 = file.blob; // This is not a blob but a uint8array var metadata = file.metadata; + // if it exists, dropEvent contains the new pad location in the drive + var dropEvent = file.dropEvent; + var key = Nacl.randomBytes(32); var next = FileCrypto.encrypt(u8, metadata, key); @@ -73,6 +76,7 @@ define([ if (noStore) { return void onComplete(href); } + common.initialPath = dropEvent && dropEvent.path; common.renamePad(title || "", href, function (err) { if (err) { return void console.error(err); } onComplete(href); diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index a2abd006a..b4e167690 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -93,7 +93,6 @@ define([ var metadata = file.metadata; var id = file.id; var dropEvent = file.dropEvent; - delete file.dropEvent; if (queue.inProgress) { return; } queue.inProgress = true; diff --git a/www/drive/inner.js b/www/drive/inner.js index 617a706ac..689627454 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1038,7 +1038,11 @@ define([ }; var onFileDrop = APP.onFileDrop = function (file, e) { - APP.FM.onFileDrop(file, e); + var ev = { + target: e.target, + path: findDropPath(e.target) + }; + APP.FM.onFileDrop(file, ev); }; var findDropPath = function (target) { var $target = $(target); @@ -1474,7 +1478,8 @@ define([ }).on('change', function (e) { var file = e.target.files[0]; var ev = { - target: $content[0] + target: $content[0], + path: findDropPath($content[0]) }; APP.FM.handleFile(file, ev); }); @@ -2847,24 +2852,7 @@ define([ var fmConfig = { noHandlers: true, onUploaded: function (ev, data) { - try { - // Get the folder path - console.log(ev.target); - console.log(data); - var newPath = findDropPath(ev.target); - if (!newPath) { return void refresh(); } - var href = data.url; - // Get the current file location in ROOT - var id = filesOp.getIdFromHref(href); - var paths = filesOp.findFile(id); - if (paths.length !== 1) { return; } - // Try to move and refresh - moveElements([paths[0]], newPath, true); - refresh(); - } catch (e) { - console.error(e); - refresh(); - } + refresh(); }, body: $('body') };