Skip to content

Commit

Permalink
Fixes Studio-42#3689, fm.sync removes unavailable volumes.
Browse files Browse the repository at this point in the history
This is an amendment to the previous commit. When invoking the refresh
action on a non-root folder, ElFinder also makes a "tree" request to the
server and adds all root volumes it currently knows about. Sinc other
parts of the code might rely upon this behavior (such as tree.js), remove
non-existent volumes from the response to the tree command in the fm.sync
method.
  • Loading branch information
awa-xima committed Dec 15, 2024
1 parent c3f6c67 commit 49b27aa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3094,9 +3094,11 @@ var elFinder = function(elm, opts, bootCallback) {
return c;
},
comp = compare(),
odataRoots,
dfrd = $.Deferred().always(function() { !reqFail && self.trigger('sync'); }),
tree = (! onlydir && this.ui.tree) ? 1 : 0,
opts = [this.request({
data : {cmd : 'open', reload : 1, target : cwd, tree : (! onlydir && this.ui.tree) ? 1 : 0, compare : comp},
data : {cmd : 'open', reload : 1, target : cwd, tree : tree, compare : comp},
preventDefault : true
})],
exParents = function() {
Expand Down Expand Up @@ -3188,7 +3190,14 @@ var elFinder = function(elm, opts, bootCallback) {
if (!self.validResponse('tree', pdata)) {
return dfrd.reject((pdata.norError || 'errResponse'));
}


// When tree = 1, the server will return all volumes in response to the open command.
// Remove volumes from the tree command that do not exist anymore.
if (tree && pdata && pdata.tree) {
odataRoots = $.map($.grep(odata.files, function(f) {return f.isroot;}), function(f) {return f.hash;});
pdata.tree = $.grep(pdata.tree, function(f) {return !f.isroot || odataRoots.indexOf(f.hash) >= 0;});
}

var diff = self.diff(odata.files.concat(pdata && pdata.tree ? pdata.tree : []), onlydir);

diff.added.push(odata.cwd);
Expand Down

0 comments on commit 49b27aa

Please sign in to comment.