mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Fix issues with findFile
This commit is contained in:
parent
2130e3339a
commit
bb5f8f734f
@ -235,11 +235,25 @@ define([
|
||||
var findFile = function (Env, id) {
|
||||
var ret = [];
|
||||
var userObjects = _getUserObjects(Env);
|
||||
let mainRes = {};
|
||||
userObjects.forEach(function (uo) {
|
||||
var fPath = _getUserObjectPath(Env, uo);
|
||||
var results = uo.findFile(id);
|
||||
if (fPath) {
|
||||
var fId = Number(uo.id);
|
||||
let results;
|
||||
if (!fId) {
|
||||
// Main drive: get the paths of all the SF
|
||||
// in addition to the paths of the requested file
|
||||
let ids = [id];
|
||||
let fIds = userObjects.map(uo => {
|
||||
return +uo.id;
|
||||
}).filter(Boolean);
|
||||
Array.prototype.push.apply(ids, fIds);
|
||||
mainRes = uo.findFiles(ids); // Store paths of each SF
|
||||
results = mainRes[id]; // Paths of requested file
|
||||
} else {
|
||||
results = uo.findFile(id);
|
||||
// This is a shared folder, we have to fix the paths in the results
|
||||
let fPath = (mainRes[fId] || [])[0];
|
||||
if (!fPath) { return; } // Can't search into this sf
|
||||
results.forEach(function (p) {
|
||||
Array.prototype.unshift.apply(p, fPath);
|
||||
});
|
||||
@ -263,9 +277,7 @@ define([
|
||||
Array.prototype.push.apply(ids, fIds);
|
||||
}
|
||||
var results = uo.findFiles(ids);
|
||||
if (!uo.id) {
|
||||
mainRes = results;
|
||||
}
|
||||
if (!uo.id) { mainRes = results; }
|
||||
//console.error(results);
|
||||
if (fId) {
|
||||
// This is a shared folder, we have to fix the paths in the results
|
||||
|
||||
@ -609,13 +609,13 @@ define([
|
||||
return _findFileInRoot([ROOT], files);
|
||||
};
|
||||
*/
|
||||
var _findFileInHrefArray = function (rootName, files) {
|
||||
var _findFileInHrefArray = function (rootName, toFind) {
|
||||
if (sharedFolder) { return {}; }
|
||||
if (!files[rootName]) { return {}; }
|
||||
var unsorted = files[rootName].slice();
|
||||
var ret = {};
|
||||
var i = -1;
|
||||
files.forEach(file => {
|
||||
toFind.forEach(file => {
|
||||
while ((i = unsorted.indexOf(file, i+1)) !== -1){
|
||||
ret[file] ||= [];
|
||||
ret[file].push([rootName, i]);
|
||||
@ -650,7 +650,7 @@ define([
|
||||
nPath.push('element');
|
||||
if (isFile(el.element)) {
|
||||
files.some(file => {
|
||||
if (compareFiles(file, root)) {
|
||||
if (compareFiles(file, el.element)) {
|
||||
paths[file] ||= [];
|
||||
paths[file].push(nPath);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user