Skip to content

Refresh does not remove volumes not available anymore #3689

Open
@blutorange

Description

Describe the bug

Volumes may stop being available (such as virtual volumes from a database and the volume was deleted from the database by another user). Doing a reload should detect this case and remove the volume, but currently, it does not.

To Reproduce

Open ElFinder with several volumes. Do something on the server that results in one volume not being available anymore. Right click -> Reload or call fm.sync on the file manager instance.

Expected behavior

ElFinder makes an open request to server, with tree = 1. The server replies with a list of all volumes.

If a volume is missing in the response from the server, ElFinder should remove that volume from the UI.

Additional context

ElFinder already checks for removed files / volumes when fm.sync is called. However, there's this part:

elFinder/js/elFinder.js

Lines 2507 to 2527 in 7544918

var resolve = function() {
var pushLeafRoots = function(name) {
if (self.leafRoots[data.target] && response[name]) {
$.each(self.leafRoots[data.target], function(i, h) {
var root;
if (root = self.file(h)) {
response[name].push(root);
}
});
}
},
setTextMimes = function() {
self.textMimes = {};
$.each(self.res('mimes', 'text'), function() {
self.textMimes[this.toLowerCase()] = true;
});
},
actionTarget;
if (isOpen) {
pushLeafRoots('files');

Where ElFinder merged the roots it already knows about into the response. If I understand it correctly, it should not do that for the open command with tree = 1, as the server will already return all available volumes.

Adding a simple check so that it only calls pushLeafRoots when tree != 1 seems to solve the issue -- the volume gets removed.

Here's a demonstration where another user removes a volume. In the first request, the server still returns the volume New theme 4. After it was deleted, the server does not return it anymore. After adding the above-mentioned check, refreshing removes the volume:

Screencast.from.2024-12-13.20-31-25.webm

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions