From 8eccffd8e41d0287a2c9ef37055cf91e6eef3b57 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Jul 2018 14:49:35 +0200 Subject: [PATCH 1/2] Don't remove migrated read-only pads --- www/common/outer/userObject.js | 40 +++++++++++++++++++--------------- www/drive/inner.js | 5 +++++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index 31e70a3bb..6477170ee 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -563,34 +563,40 @@ define([ continue; } // Clean missing href - if (!el.href) { - debug("Removing an element in filesData with a missing href.", el); - toClean.push(id); - continue; - } + if (el.href) { + if (!el.href) { + debug("Removing an element in filesData with a missing href.", el); + toClean.push(id); + continue; + } - var parsed = Hash.parsePadUrl(el.href); - // Clean invalid hash - if (!parsed.hash) { - debug("Removing an element in filesData with a invalid href.", el); - toClean.push(id); - continue; - } - // Clean invalid type - if (!parsed.type) { - debug("Removing an element in filesData with a invalid type.", el); + var parsed = Hash.parsePadUrl(el.href); + // Clean invalid hash + if (!parsed.hash) { + debug("Removing an element in filesData with a invalid href.", el); + toClean.push(id); + continue; + } + // Clean invalid type + if (!parsed.type) { + debug("Removing an element in filesData with a invalid type.", el); + toClean.push(id); + continue; + } + } else if (!el.roHref) { + debug("Removing an element in filesData with a missing href.", el); toClean.push(id); continue; } // Fix href - if (/^https*:\/\//.test(el.href)) { el.href = Hash.getRelativeHref(el.href); } + if (el.href && /^https*:\/\//.test(el.href)) { el.href = Hash.getRelativeHref(el.href); } // Fix creation time if (!el.ctime) { el.ctime = el.atime; } // Fix title if (!el.title) { el.title = Hash.getDefaultName(parsed); } // Fix channel - if (!el.channel) { + if (el.href && !el.channel) { try { var secret = Hash.getSecrets(parsed.type, parsed.hash, el.password); el.channel = secret.channel; diff --git a/www/drive/inner.js b/www/drive/inner.js index d072992d6..8454cff32 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -1367,6 +1367,10 @@ define([ } var element = filesOp.find(newPath); + if (!isFolder) { + var data = filesOp.getFileData(element); + if (!data.href) { return; } + } var $icon = !isFolder ? getFileIcon(element) : undefined; var ro = filesOp.isReadOnlyFile(element); // ro undefined means it's an old hash which doesn't support read-only @@ -2424,6 +2428,7 @@ define([ sortedFiles.forEach(function (key) { if (filesOp.isFolder(root[key])) { return; } var $element = createElement(path, key, root, false); + if (!$element) { return; } $element.appendTo($list); }); From f97685cc15ca30393e10056a14ccf1c96b551941 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Jul 2018 15:12:07 +0200 Subject: [PATCH 2/2] lint compliance --- www/common/outer/userObject.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index 6477170ee..f933b1153 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -563,6 +563,7 @@ define([ continue; } // Clean missing href + var parsed; if (el.href) { if (!el.href) { debug("Removing an element in filesData with a missing href.", el); @@ -570,7 +571,7 @@ define([ continue; } - var parsed = Hash.parsePadUrl(el.href); + parsed = Hash.parsePadUrl(el.href); // Clean invalid hash if (!parsed.hash) { debug("Removing an element in filesData with a invalid href.", el);