matthewbdaly/laravel-azure-storage

Calling exists on directory returns false

eldiddio opened this issue · 4 comments

Hello,

Thank you for the package, I have used this for a few years and it has been amazing.

I have recently started using Spatie Media Library with Azure storage, when deleting a media model the related files and directories does not get removed. After looking over the code I have pinned the issue down to the command "exists" getting called on a directory and returning false when the directory exists.

use Illuminate\Support\Facades\Storage;
dd(
    Storage::has('16'),
    Storage::has('16/'),
    Storage::exists('16'),
    Storage::exists('16/'),
    Storage::allDirectories()
);

Produces:

false
false
false
false
array:1 [▼
  0 => "16"
]

If I swap to the local file adapter and add the folder this works as expected.

Exists is called in the media library and is returning false which is leaving the files on the azure storage: Spatie Media Library Filesystem

Storage::deleteDirectory('16'); works as expected and the folder deletes without issue.

Versions:
Laravel: 8.68.1
Azure-storage: 1.6.2

Any help with this would be great,

Thanks

Does it work OK if you resolve the Flysystem instance from the container and call the has() method on that? Given this library is just a Laravel wrapper around the Azure bindings for Flysystem, my first thought is that the problem is more likely to be there.

Hi,

Do you mean trying:

$filesystem = app('filesystem')

I am happy to run more tests

Thanks

No. The Laravel filesystem API is basically just a wrapper around the PHP League's Flysystem project, and this package just provides an adapter for using Azure blob storage with that.

As such, it doesn't actually implement the functionality you're using. That functionality is actually implemented in the Flysystem Azure driver, so I suspect that it's more likely to be an issue with that driver.

What I'd like to check is what happens if you instantiate the Flysystem instance directly from the Laravel container rather than using the Laravel storage API, then try calling the method I mentioned on it. If it doesn't work, that would point to any issue being with the Azure driver for Flysystem.

Closing as no activity