-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Write files using create_new
option to avoid accidental overwrites
#855
Conversation
The previously used `File::create` silently overwrites existing files, which causes problems e.g. when two pages accidentally specify the same `path`. By opening all files with the `create_new` option, we can ensure that no files are overwritten.
This approach is a bit more far-reaching than only checking for path collisions, but I think it is a good sanity check. The error message that occurs for duplicate files is still ok, e.g.:
|
That works but I would prefer having a full report on why it is failing, eg which files are conflicting. |
I understand. However I still think that the |
To clarify: I think there should be both: A nice error report and a sanity check that no files are overwritten. |
Ok, from the CI tests it seems like there are a few cases where Zola does indeed overwrite files:
I guess we could fix those by deleting the existing content before recreating it (i.e. once before zola starts writing files). This would also ensure that we have no stale files left over from previous runs. Let me know if I should try something like this or if you prefer to close this PR! |
Very good point. But in that specific case of rebuilding, we do want to overwrite files otherwise |
I see. Seems like this approach isn't the right on then. |
The previously used
File::create
silently overwrites existing files, which causes problems e.g. when two pages accidentally specify the samepath
. By opening all files with thecreate_new
option, we can ensure that no files are overwritten.Fixes #366