mirror of
https://github.com/Studio-42/elFinder
synced 2026-06-08 12:37:09 +00:00
* Fixes Studio-42/elFinder#3689, fm.sync removes unavailable volumes. When a request is made to the server with the open command and tree=1, the server must reply with a list of all volumes. If the server's response does not include a volume ElFinder already knows about, that volume should be treated as not available anymore and get removed from the file explorer UI. * Fixes Studio-42/elFinder#3689, fm.sync removes unavailable volumes. 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. --------- Co-authored-by: Andre Wachsmuth <awa@xima.de>
This commit is contained in:
+14
-3
@@ -2302,6 +2302,8 @@ var elFinder = function(elm, opts, bootCallback) {
|
||||
isBinary = (opts.options || {}).dataType === 'binary',
|
||||
// current cmd is "open"
|
||||
isOpen = (!opts.asNotOpen && cmd === 'open'),
|
||||
// the tree option is enabled (for "open" command)
|
||||
isTree = (data.tree === 1),
|
||||
// call default fail callback (display error dialog) ?
|
||||
deffail = !(isBinary || opts.preventDefault || opts.preventFail),
|
||||
// call default success callback ?
|
||||
@@ -2523,7 +2525,7 @@ var elFinder = function(elm, opts, bootCallback) {
|
||||
},
|
||||
actionTarget;
|
||||
|
||||
if (isOpen) {
|
||||
if (isOpen && !isTree) {
|
||||
pushLeafRoots('files');
|
||||
} else if (cmd === 'tree') {
|
||||
pushLeafRoots('tree');
|
||||
@@ -3092,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() {
|
||||
@@ -3186,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);
|
||||
|
||||
Reference in New Issue
Block a user