jekyll / jekyll-admin

A Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites.
https://jekyll.github.io/jekyll-admin/
MIT License
2.82k stars 357 forks source link

Files are displayed duplicated after saving #699

Closed rpeyron closed 1 year ago

rpeyron commented 1 year ago

Description:

Files are displayed duplicated after saving with jekyll-admin.

Example: image

Tell us a bit about yourself:

Steps to reproduce:

Note: I have not been able to reproduce with the spec/fixtures test site ; maybe it is too fast to generate to have concurrency issues

  1. Launch with bundle exec jekyll serve --live-reload
  2. Edit a file
  3. Save the file

I expected the following:

Files are not shown duplicated

But got the following, instead:

Files are shown duplicated

The console also reports other errors as: conflicting chdir during another chdir block or content duplication warning with same source file

Conflict: The following destination is shared by multiple files.
                    The written file may end up with unexpected contents.
                    /home/remi/.roaming/work/lprp/rpeyron.github.io/_site/files/triboum.pdf
                     - /home/remi/.roaming/work/lprp/rpeyron.github.io/files/triboum.pdf
                     - /home/remi/.roaming/work/lprp/rpeyron.github.io/files/triboum.pdf

and site.collections contain all entries duplicated

Other details:

Workarounds that I found:

I guess the two lines above are triggering the same process that may cause problems when run concurrently

ashmaroli commented 1 year ago

Hello @rpeyron Is the --no-watch option needed to reproduce this? Regardless, are you willing to submit a Pull Request?

rpeyron commented 1 year ago

Hello @ashmaroli, no, on the contrary you have to not use --no-watch to reproduce the issue, as it is a workaround to solve the issue.

I am willing to help on this subject, but I don't know enough of jekyll and jekyll-admin to be sure where this problem has to be solved (maybe more related to jekyll thant jekyll-admin?). The most obvious PR I can submit is to remove the site.process in file_helper.rb that are redundant with the watch feature of jekyll serve ; as a side effect it won't update the site if jekyll-admin is used outside jekyll serve command or with --no-watch option, I don't know if this is a use case you judge important for jekyll-admin.

ashmaroli commented 1 year ago

on the contrary you have to not use --no-watch to reproduce the issue, as it is a workaround...

Ah! My apologies. I overlooked the section title. I did seem weird that --no-watch would trigger this. Hence asked you.

Anyways, pull request is welcome. The root cause is a race condition occurring between Jekyll's watching and the admin backend regeneration. We have employed temporary hacks in the past to address this issue but none held out satisfactorily through time.