spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.08k forks source link

Fix wrong deletions #3630

Closed inalto closed 5 months ago

inalto commented 5 months ago

In case of custom paths setup to save the images in the same subdirectory ex. username/post_id/photos/somefile.ext when a file is removed from the media directory it wipes all the directory content.

This commit fixes this problem only deleting the proper images (and related conversions and responsive images) and delete the directory only if is empty.

freekmurze commented 5 months ago

Hi, could you also add a test to prove that this works?

inalto commented 5 months ago

yes, I write one

inalto commented 5 months ago

hello, i added some test and spotted some bugs on DefaultFileRemover, now i look at failing tests

inalto commented 5 months ago

Problem in case of custom-named media is fixed now. And all the test are passing, included new ones.

freekmurze commented 5 months ago

Thank you very much!