diff --git a/js/elFinder.js b/js/elFinder.js index 371713eae..8e6f18029 100644 --- a/js/elFinder.js +++ b/js/elFinder.js @@ -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() { @@ -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);