Skip to content
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

Refactor: remove even more unnecessary create_directory #2428

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Jan 28, 2024

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you doing the PR on the next branch?

These are some things that were missed even by #2407.

After doing some more investigation, even copying files will automatically create directories, so, we don't need these calls either. It simplifies the code a bit more and will also ensure that directories aren't created unless files are actually inside them.

Another reason for this change is it also makes calls to write_content and write_section a bit less confusing, since right now, if multiple calls to it are made, the final argument is set to false to avoid doing work, which can make following the code a bit more challenging since it's not always clear when this argument is applied.


One small change here: this adds the same create-parent logic to create_file as copy_file and copy_file_if_needed, so that these three methods are consistent. Part of the reason why these were necessary before was because directories had to be manually created sometimes, and this was a bit inconsistent, so, this PR fixes that.

@Keats
Copy link
Collaborator

Keats commented Jan 28, 2024

Looks like legit CI failures?

@clarfonthey
Copy link
Contributor Author

They were, and sorry for taking so long to get back to this. Essentially, I thought that since these directories were always being made for copied files, they were also made for created files, which was not the case. I decided to go ahead and update things so that this is the case, but I understand if you'd rather not merge this PR because of that. While I personally think it makes the code simpler, that's not really an objective thing, just my opinion.

@Keats Keats merged commit 20f00ba into getzola:next Apr 23, 2024
5 checks passed
@clarfonthey clarfonthey deleted the create-directory branch April 23, 2024 20:09
veluca93 pushed a commit to veluca93/zola that referenced this pull request May 14, 2024
berdandy pushed a commit to berdandy/azola that referenced this pull request Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants