From e84503bd52878bf9b89ddcd84a9a9703b16cd63a Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 26 Feb 2020 14:05:29 +0100 Subject: [PATCH 1/2] fixFiles optimizations --- www/common/outer/userObject.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index 9cbd4b2c4..db53c1c28 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -720,13 +720,17 @@ define([ var fixTemplate = function () { if (sharedFolder) { return; } if (!Array.isArray(files[TEMPLATE])) { debug("TEMPLATE was not an array"); files[TEMPLATE] = []; } - files[TEMPLATE] = Util.deduplicateString(files[TEMPLATE].slice()); - var us = files[TEMPLATE]; - var rootFiles = exp.getFiles([ROOT]).slice(); + var dedup = Util.deduplicateString(files[TEMPLATE]); + if (dedup.length !== files[TEMPLATE].length) { + files[TEMPLATE] = dedup; + } + var us = files[TEMPLATE].slice(); + var rootFiles = exp.getFiles([ROOT]); var toClean = []; us.forEach(function (el, idx) { if (!exp.isFile(el, true) || rootFiles.indexOf(el) !== -1) { toClean.push(el); + return; } if (typeof el === "string") { // We have an old file (href) which is not in filesData: add it @@ -735,6 +739,7 @@ define([ href: exp.cryptor.encrypt(el) }; us[idx] = id; + return; } if (typeof el === "number") { var data = files[FILES_DATA][el]; @@ -878,8 +883,7 @@ define([ // Fix undefined hash parsed = Hash.parsePadUrl(href || el.roHref); - secret = Hash.getSecrets('drive', parsed.hash, el.password); - if (!secret.keys) { + if (!parsed || !parsed.hash || parsed.hash === "undefined") { delete sf[id]; continue; } From e18c224db4394fc1b71d0a0496383f2fdf675665 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 27 Feb 2020 13:33:22 +0100 Subject: [PATCH 2/2] Faster sort function in drive --- www/common/drive-ui.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index b102fba3d..f4eaa8556 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -2762,7 +2762,7 @@ define([ }); if (keys.length < 2) { return keys; } var mult = asc ? 1 : -1; - var getProp = function (el, prop) { + var getProp = function (el) { if (folder && root[el] && manager.isSharedFolder(root[el])) { var title = manager.getSharedFolderData(root[el]).title || el; return title.toLowerCase(); @@ -2777,13 +2777,19 @@ define([ return hrefData.type; } if (prop === 'atime' || prop === 'ctime') { - return new Date(data[prop]); + return typeof(data[prop]) === "number" ? data[prop] : new Date(data[prop]); } return (manager.getTitle(id) || "").toLowerCase(); }; + var props = {}; + keys.forEach(function (k) { + props[k] = getProp(k); + }); keys.sort(function(a, b) { - if (getProp(a, prop) < getProp(b, prop)) { return mult * -1; } - if (getProp(a, prop) > getProp(b, prop)) { return mult * 1; } + var _a = props[a]; + var _b = props[b]; + if (a < b) { return mult * -1; } + if (b > a) { return mult; } return 0; }); return keys;