Skip to content

Conversation

@mnightingale
Copy link
Contributor

Summary of the change: Support CacheAdapters

Laravel recommends using CachedAdapter from league/flysystem-cached-adapter to cache driver meta data.

Prior to this commit it wasn't supported by this package and throws the following exception when attempting to upload a file:

Call to undefined method League\Flysystem\Cached\CachedAdapter::getPathPrefix() {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to undefined method League\\Flysystem\\Cached\\CachedAdapter::getPathPrefix() at /SNIP/vendor/unisharp/laravel-filemanager/src/LfmStorageRepository.php:29)
[stacktrace]
#0 /SNIP/vendor/unisharp/laravel-filemanager/src/LfmPath.php(77): UniSharp\\LaravelFilemanager\\LfmStorageRepository->rootPath()
#1 /SNIP/vendor/unisharp/laravel-filemanager/src/LfmPath.php(222): UniSharp\\LaravelFilemanager\\LfmPath->path('absolute')
#2 /SNIP/vendor/unisharp/laravel-filemanager/src/Controllers/UploadController.php(34): UniSharp\\LaravelFilemanager\\LfmPath->upload(Object(Illuminate\\Http\\UploadedFile))
#3 [internal function]: UniSharp\\LaravelFilemanager\\Controllers\\UploadController->upload()

The fix in this PR is similar to as used in laravel/framework at https://github.com/laravel/framework/blob/5.7/src/Illuminate/Filesystem/FilesystemAdapter.php#L376-L397 in that it unwraps the CachedAdapter.

It has made a significant improvement to my file listing performance with S3.

@streamtw
Copy link
Member

streamtw commented Nov 8, 2018

We notice there is some serious performance issue with S3 when integrating laravel file system, just cannot figure why. So glad to receive this PR! Thanks @mnightingale !

@streamtw streamtw merged commit 221b785 into UniSharp:master Nov 8, 2018
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 this pull request may close these issues.

2 participants