diff --git a/www/common/userObject.js b/www/common/userObject.js index 4c21084b0..e6cc4a698 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -889,6 +889,13 @@ define([ element[key] = id; delete element[el]; } + if (typeof element[el] === "number") { + var data = files[FILES_DATA][element[el]]; + if (!data) { + debug("An element in ROOT doesn't have associated data", element[el], el); + delete element[el]; + } + } } }; var fixTrashRoot = function () { @@ -906,6 +913,14 @@ define([ obj.element = id; } if (isFolder(obj.element)) { fixRoot(obj.element); } + if (typeof obj.element === "number") { + var data = files[FILES_DATA][obj.element]; + if (!data) { + debug("An element in TRASH doesn't have associated data", obj.element, el); + delete element[el]; + } + } + }; for (var el in tr) { if (!Array.isArray(tr[el])) { @@ -943,6 +958,13 @@ define([ files[FILES_DATA][id] = {href: el}; us[idx] = id; } + if (typeof el === "number") { + var data = files[FILES_DATA][el]; + if (!data) { + debug("An element in TEMPLATE doesn't have associated data", el); + delete element[el]; + } + } }); toClean.forEach(function (idx) { us.splice(idx, 1); diff --git a/www/drive/main.js b/www/drive/main.js index 88fe7a0fd..b35faf881 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -1569,7 +1569,7 @@ define([ if (prop === 'atime' || prop === 'ctime') { return new Date(data[prop]); } - return filesOp.getTitle(id).toLowerCase(); + return (filesOp.getTitle(id) || "").toLowerCase(); }; keys.sort(function(a, b) { if (getProp(a, prop) < getProp(b, prop)) { return mult * -1; } @@ -1605,7 +1605,7 @@ define([ return new Date(e[prop]); } } - return el.name.toLowerCase(); + return (el.name || "").toLowerCase(); }; keys.sort(function(a, b) { if (getProp(a, prop) < getProp(b, prop)) { return mult * -1; }