mage2tv / magento-cache-clean

A faster drop in replacement for bin/magento cache:clean with file watcher
BSD 3-Clause "New" or "Revised" License
527 stars 61 forks source link

Frontend Cache-Clean [F] does not seem to clear static content #105

Open kolaente opened 2 years ago

kolaente commented 2 years ago

When pressing F, the files in pub/static/frontend are still present.

Vinai commented 2 years ago

Thanks for opening the issue @kolaente - I must have broken it at one point in time!

Vinai commented 2 years ago

I am unable to reproduce the issue.
When I press F the files in pub/static/frontend are gone, only the directories remain.


My steps to reproduce on my current dev instance:

  1. Reload the homepage after clearing static view files.
  2. Then, list all files and symlinks (because I am running in deploy mode developer).
    $ find pub/static/frontend/ -type f -or -type l
    pub/static/frontend/Hyva/default/de_CH/Magewirephp_Magewire/js/livewire.js
    pub/static/frontend/Hyva/default/de_CH/Magewirephp_Magewire/js/livewire.js.map
    pub/static/frontend/Hyva/default/de_CH/css/styles.css
    pub/static/frontend/Hyva/default/de_CH/Hyva_Theme/js/alpine.min.js
    pub/static/frontend/Hyva/default/de_CH/Hyva_Theme/js/alpine.min.js.map
    pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/owlcarousel/owl.carousel.min.css
    pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/styles.css
    pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/mgz_bootstrap.css
    pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/fontawesome5.css
    pub/static/frontend/Hyva/default/de_CH/Magento_Theme/favicon.ico
    pub/static/frontend/Hyva/default/de_CH/images/hero-2x.jpg
    pub/static/frontend/Hyva/default/de_CH/images/hyva-logo.svg
    pub/static/frontend/Hyva/default/de_CH/images/logo.svg
  3. Press F in the cache-watcher
  4. Finally, list all files and symlinks, again
    $ find pub/static/frontend/ -type f -or -type

Result: no files are left.

Vinai commented 2 years ago

Please let me know if I am missing a step when reproducing the issue.

sprankhub commented 1 year ago

I just (partially) bumped into this issue. In general, [F] clears static content files for me. However, it seems to not clear any broken symlinks. So if there is a broken symlink under pub/static, this broken symlink will not be removed, which may lead to issues.

Use case:

  1. Override a file in your theme.
  2. Open the page, so that the symlink for this file is created.
  3. Remove the file from your theme, because you do not want to override it any more.
  4. Press [F].

Expected: The broken symlink of the old overridden file is removed. Actual: The broken symlink is not removed, so that Magento is missing a file in the frontend.

Vinai commented 1 year ago

That's interesting. I wonder why the broken symlinks are not removed. If I recall correctly, this function should remove them, too...

sprankhub commented 1 year ago

I just bumped into this again. I have no idea about ClojureScript, but I figured the files are unlinked via the rm function. Could it be that the following exists? check returns false for broken symlinks, so that they are not unlinked?

https://github.com/mage2tv/magento-cache-clean/blob/d95b541d6f7bca9098f604f1b2b951bac29954c3/src/file/system.cljs#L75