-
Notifications
You must be signed in to change notification settings - Fork 991
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: create_directory responsibly #2407
Conversation
…ry, and misleading
…d of manually iterating over components
@@ -977,8 +970,6 @@ impl Site { | |||
|
|||
/// What it says on the tin | |||
pub fn render_sitemap(&self) -> Result<()> { | |||
ensure_directory_exists(&self.output_path)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep those around even if in theory it's already created elsewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I removed it here is because write_content
always creates directories when called, so, you can rely on that instead of creating them ahead of time.
This is why the only remaining instances where directories created are there, and when copying assets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok in the grand scheme of things but creates inter-dependencies in case we decide to not use write_content for some reason. Maybe it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair. My thought process was that we should delay creating the directory as long as possible to avoid making them unnecessarily, but I'm open to adding back in checks that are guarded on whether things will actually be written.
* Remove ensure_directory_exists since it's identical to create_directory, and misleading * Don't create directories unless needed; rely on create_dir_all instead of manually iterating over components
* Remove ensure_directory_exists since it's identical to create_directory, and misleading * Don't create directories unless needed; rely on create_dir_all instead of manually iterating over components
* Remove ensure_directory_exists since it's identical to create_directory, and misleading * Don't create directories unless needed; rely on create_dir_all instead of manually iterating over components
These are the first two commits of #2388 separated into their own PR. Specifically:
ensure_directory_exists
was made identical tocreate_directory
. I removed the former and replaced all instances with the latter.create_directory
iteratively on every component despite it usingcreate_dir_all
internally. I decided to update these to have fewercreate_directory
calls so they could be better tracked.