-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent directory modifications when iterating #515
Prevent directory modifications when iterating #515
Conversation
Thank you for the work and new clean PR :) With your previous PR, I noticed the the cs-fixer wasn't using the current Nextcloud guidelines (but our code was), so I updated them. I think you can skip the formatting commit. |
I didn't do the But there is still one failing check and I do not understand what I am supposed to do with it. |
I tried to generate the |
Thanks. And it seems to pass now. But you misst to sign your commit. -> I am glad I am not the only one doing that mistake :) |
Seems good. |
Yes, I only did a fixup :) |
Signed-off-by: CaCO3 <caco@ruinelli.ch>
Signed-off-by: CaCO3 <caco@ruinelli.ch>
This can lead to skipped files! Signed-off-by: CaCO3 <caco@ruinelli.ch>
Signed-off-by: CaCO3 <caco@ruinelli.ch>
Signed-off-by: CaCO3 <caco@ruinelli.ch>
Signed-off-by: CaCO3 <caco@ruinelli.ch>
d283b28
to
ff5f586
Compare
Signed-off-by: CaCO3 <caco@ruinelli.ch>
Signed-off-by: CaCO3 <caco@ruinelli.ch>
This can lead to skipped files! Signed-off-by: CaCO3 <caco@ruinelli.ch>
…ps://github.com/caco3/updater into prevent-directory-modifications-when-iterating2
@Altahrim thanks for merging How will we find out which NC release is going to contain this fix? Through the NC release notes? |
I also would suggest to have a look on all other usages of |
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! |
This PR solves the failing updates due to issues on removing the old files and copying the new files.
See #158 for details.
And it also solves the issue some systems have when modifying a directory while iterating through it, see #509 for details.
TL;DR
On some servers (notable
FreeBSD 12.4
on hostspoint.ch), the updater tries tormdir()
non-empty folders. This is not supported on PHP. The updater already has a function to recursively delete (recursiveDelete()
), how ever it is not used consistently.Additionally, the iterator gets gets messed up in the move step when modifying the directories. Thus we copy() instead of rename() and remove the whole folders/files afterwards in a separate iteration.
Scroll down for the fix.
Issue
Updater fails to delete old files:
updater log on first deletion failure:
The general issue seems to be that rmdir only is able to delete empty folders.
The first time the issue occurs for me is on deleting the
lib/l10n
folder.Looking on the folder, it clearly is not empty at that time:
> ls af.json az.js br.js el.js es_AR.json es_EC.json es_PR.json fo.js gd.json hy.js id.json km.js lb.js mk.json nl.json pt_BR.js si.js th.js vi.json an.js az.json bs.js el.json es_CL.js es_HN.json es_UY.json fo.json he.js hy.json is.json kn.js lb.json ms_MY.js oc.js pt_BR.json sk.js th.json zh_CN.js ar.js be.js cs.json eo.js es_CL.json es_MX.json et_EE.json fr.js hr.json ia.js it.js kn.json lo.json nb.json pl.js pt_PT.js sq.js tk.json zh_TW.js ast.js bg.json da.js eo.json es_CO.js es_NI.json eu.json fr.json hu.js ia.json ja.js ko.js lt_LT.json ne.json pl.json pt_PT.json sq.json ur_PK.js ast.json bn_BD.js de_DE.json es_419.js es_DO.js es_PE.js fi.json gd.js hu.json id.js ka_GE.js ko.json lv.json nl.js ps.js sc.json ta.json ur_PK.json
Note that it still contains 93 files. Odly, originally it contained 200 files, so some successed to get deleted...
Fix
rmdir()
andunlink()
.Using that fix, I am successful to update Nextcloud
27.0.0
to the latest (currently27.1.2
).