barryvdh / elfinder-flysystem-driver

elFinder driver for Flysystem
183 stars 41 forks source link

cacheing hasdir and add option 'disableEnsureParentDirectories' #38

Closed nao-pon closed 8 years ago

nao-pon commented 8 years ago

prototype quality

barryvdh commented 8 years ago

I'm not really sure what this does. Do we really need hasDir()?

barryvdh commented 8 years ago

Can't we just do this for _subdirs:

protected function _subdirs($path)
    {
        $contents = $this->fs->listContents($path);

        $dirs = array_filter($contents, function($item){
            return $item['type'] == 'dir';
        });

        return ! empty($dirs);
    }

And to check if the folder/file exists:

try {
        $meta = $this->fs->getMetadata($path);
} catch (\Exception $e) {
       return array();
}

It seems that FTP and local are now returning true on has() calls for directories. Do we still need the hasDir call?

nao-pon commented 8 years ago

There is an adapter that contains the value of the hasDir to metadata. (Such as flysystem-google-drive). We can be the perfect cache that does not cause the API calls such adapter. Like a demo site.

barryvdh commented 8 years ago

Can't you just return true on the has($dir) call?

nao-pon commented 8 years ago

has($dir) is "exists "$dir"?" but hasDir($dir) is "Have "$dir" sub-dirctory?".

barryvdh commented 8 years ago

Okay but checking the listContents() has the same effect, right? Both require an API call.

barryvdh commented 8 years ago

And for what reason do we need to check if they have subdirs?

nao-pon commented 8 years ago

On flysystem-google-drive, To optimize the API call gets the value of hasDir() in the target directory listContents().

And for what reason do we need to check if they have subdirs?

If there is a sub-directory in the tree view of elFinder comes out a triangle icon.

barryvdh commented 8 years ago

It's just that we need a lot of extra stuff, just for the Google Drive stuff, because it's different then the other drivers..

nao-pon commented 8 years ago

I agree. I want to create something that corresponds to also other adapter hasDir. But does not have the time...

For GoogleDrive adapter chooses to pass adapter loaded with cached adapter.

Thanks! :laughing: