Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
ansuz 5 years ago
commit d2bae175c4

@ -2762,7 +2762,7 @@ define([
}); });
if (keys.length < 2) { return keys; } if (keys.length < 2) { return keys; }
var mult = asc ? 1 : -1; var mult = asc ? 1 : -1;
var getProp = function (el, prop) { var getProp = function (el) {
if (folder && root[el] && manager.isSharedFolder(root[el])) { if (folder && root[el] && manager.isSharedFolder(root[el])) {
var title = manager.getSharedFolderData(root[el]).title || el; var title = manager.getSharedFolderData(root[el]).title || el;
return title.toLowerCase(); return title.toLowerCase();
@ -2777,13 +2777,19 @@ define([
return hrefData.type; return hrefData.type;
} }
if (prop === 'atime' || prop === 'ctime') { 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(); return (manager.getTitle(id) || "").toLowerCase();
}; };
var props = {};
keys.forEach(function (k) {
props[k] = getProp(k);
});
keys.sort(function(a, b) { keys.sort(function(a, b) {
if (getProp(a, prop) < getProp(b, prop)) { return mult * -1; } var _a = props[a];
if (getProp(a, prop) > getProp(b, prop)) { return mult * 1; } var _b = props[b];
if (a < b) { return mult * -1; }
if (b > a) { return mult; }
return 0; return 0;
}); });
return keys; return keys;

@ -720,13 +720,17 @@ define([
var fixTemplate = function () { var fixTemplate = function () {
if (sharedFolder) { return; } if (sharedFolder) { return; }
if (!Array.isArray(files[TEMPLATE])) { debug("TEMPLATE was not an array"); files[TEMPLATE] = []; } if (!Array.isArray(files[TEMPLATE])) { debug("TEMPLATE was not an array"); files[TEMPLATE] = []; }
files[TEMPLATE] = Util.deduplicateString(files[TEMPLATE].slice()); var dedup = Util.deduplicateString(files[TEMPLATE]);
var us = files[TEMPLATE]; if (dedup.length !== files[TEMPLATE].length) {
var rootFiles = exp.getFiles([ROOT]).slice(); files[TEMPLATE] = dedup;
}
var us = files[TEMPLATE].slice();
var rootFiles = exp.getFiles([ROOT]);
var toClean = []; var toClean = [];
us.forEach(function (el, idx) { us.forEach(function (el, idx) {
if (!exp.isFile(el, true) || rootFiles.indexOf(el) !== -1) { if (!exp.isFile(el, true) || rootFiles.indexOf(el) !== -1) {
toClean.push(el); toClean.push(el);
return;
} }
if (typeof el === "string") { if (typeof el === "string") {
// We have an old file (href) which is not in filesData: add it // We have an old file (href) which is not in filesData: add it
@ -735,6 +739,7 @@ define([
href: exp.cryptor.encrypt(el) href: exp.cryptor.encrypt(el)
}; };
us[idx] = id; us[idx] = id;
return;
} }
if (typeof el === "number") { if (typeof el === "number") {
var data = files[FILES_DATA][el]; var data = files[FILES_DATA][el];
@ -878,8 +883,7 @@ define([
// Fix undefined hash // Fix undefined hash
parsed = Hash.parsePadUrl(href || el.roHref); parsed = Hash.parsePadUrl(href || el.roHref);
secret = Hash.getSecrets('drive', parsed.hash, el.password); if (!parsed || !parsed.hash || parsed.hash === "undefined") {
if (!secret.keys) {
delete sf[id]; delete sf[id];
continue; continue;
} }

Loading…
Cancel
Save