Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh does not remove volumes not available anymore #3689

Open
blutorange opened this issue Dec 13, 2024 · 0 comments · May be fixed by #3690
Open

Refresh does not remove volumes not available anymore #3689

blutorange opened this issue Dec 13, 2024 · 0 comments · May be fixed by #3690

Comments

@blutorange
Copy link
Contributor

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
blutorange pushed a commit to blutorange/elFinder that referenced this issue Dec 13, 2024
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.
@blutorange blutorange linked a pull request Dec 13, 2024 that will close this issue
blutorange pushed a commit to blutorange/elFinder that referenced this issue Dec 15, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant