fixFiles optimizations

pull/1/head
yflory 5 years ago
parent 87ef2b0899
commit e84503bd52

@ -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;
}

Loading…
Cancel
Save