Elfinder: Incorrect filepath returned. Missing parent folder information when selecting file before tree loads

Created on 31 Oct 2016  路  6Comments  路  Source: Studio-42/elFinder

Hello,

In our version of elFinder, when a user selects a file, the filepath is displayed for the user using fm.escape(fm.path(file.hash, true));

If elfinder is loading a non-root directory because of rememberLastDir and the user selects a file before the file tree on the left fully loads, the parent folder information is missing and the full filepath is not given. Instead elFinder returns only the file and the immediate directory it is inside.

So instead of elFinder returning: _'root/directory/subdirectory/foo.txt'_ - it returns _'subdirectory/foo.txt'_

We are on elFinder version 2.1.9.

In our connector.php:

$opts = array(
    // 'debug' => true,
    'roots' => array(
        array(
            'driver'        => 'LocalFileSystem',           // driver for accessing file system (REQUIRED)
            'path'          => $_REQUEST['path'],                 // path to files (REQUIRED)
            'tmbPath'       => false,
            'quarantine'    => false,
            // 'URL'           => dirname($_SERVER['PHP_SELF']) . '/../../projects/', // URL to files (REQUIRED)
            'uploadDeny'    => array('all'),                // All Mimetypes not allowed to upload
            // 'uploadAllow'   => array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload
            'uploadOrder'   => array('deny', 'allow'),      // allowed Mimetype `image` and `text/plain` only
            'accessControl' => 'access',                     // disable and hide dot starting files (OPTIONAL)
            'checkSubfolders' => false,
            'mimeMap'         => array(
                'idml:application/zip'  => 'application/idml'
            )
        )
    )
);
client bug

Most helpful comment

It done. We can request to get path as async. (Automatically perform the async request in getFileCallback.)

e.g. for your custom function

fm.escape(fm.path(file.hash, true));

to

fm.path(file.hash, true, {}).done(function(path) {
    fm.escape(path);
});

if you don't need notify

fm.path(file.hash, true, {notify: null}).done(function(path) {
    fm.escape(path);
});

All 6 comments

@YanareKu It seems no problen on the current version. Could you check on the current version or nightly build?

Hello @nao-pon - we updated to the current version, but the issue persists. The problem only happens when there are slightly longer than normal delays on elFinder reading the filesystem and the user clicks on the file before the file tree loads.

I will try to create a mock-up repo later today to help show the issue. Also, thank you for elFinder - we love it very much and it is very helpful.

We're mounting a filesystem that is sometimes slow to load -- Here's a test repo with a bit of a delay added to help expose the bug:

https://github.com/featheredtoast/elFinder/commit/39e0adefa615b283a0f508a9402122c259486418#diff-6743f87bed1eebb265628e15d079f7f3R658

Here it is in action. Log statements are shown when double clicking and firing the getFileCallback handler - once before the file tree is loaded, and once afterwards:
out

The path is correct for a single subdirectory down (eg files/foo/b.txt), but the bug seems to come up in successive descendants. (files/foo/bar/c.txt as shown in the gif.)

@YanareKu , @featheredtoast I got it. This is a bug of cmd getfile. I'll fix it.

Thank you so much!

It done. We can request to get path as async. (Automatically perform the async request in getFileCallback.)

e.g. for your custom function

fm.escape(fm.path(file.hash, true));

to

fm.path(file.hash, true, {}).done(function(path) {
    fm.escape(path);
});

if you don't need notify

fm.path(file.hash, true, {notify: null}).done(function(path) {
    fm.escape(path);
});
Was this page helpful?
0 / 5 - 0 ratings