cap340 / CleanMedia

Magento 2 CLI Command : remove images of deleted product in the /media/catalog/product folder
29 stars 16 forks source link

Add an option to limit the number of files #14

Open VincentMarmiesse opened 4 years ago

VincentMarmiesse commented 4 years ago

Hi,

It would be nice to have an option to limit the number of files the command browses. I just runned it on a Magento with 5M+ files and the NFS server is running down.

Maybe something like php bin/magento cap:clean:media --limit=XXX.

cap340 commented 4 years ago

Hi, I'm facing same kind of issues, include the cache folder in iteration seems not to be the best solution... I'm working on an update without the cache (we still can flush it after using Magento admin option) in which I will add your very good idea of ​​limit option. Thanks a lot

cap340 commented 4 years ago

Hi, Could you test the dev branch version ? there is 2 options in the command line :

You could combine both options php bin/magento cap:clean:media --dry-run --limit=10

The slowest part of the previous command was the double media folder iteration... I also removed the database cleaner part for now (explain in the README.md)

Thanks

gerben86 commented 10 months ago

Wouldn't it make more sense to check for each file in the database if it actual exists on the disk and then delete it? In that case there's no need to do the media folder iteration.

  1. So iterate through the database results 1.A Check for each file if it exists 1.B If it exists delete it
  2. Clean database