-
Notifications
You must be signed in to change notification settings - Fork 59
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
fix: Only copy pre-compiled themes once #1184
Conversation
R/bs-dependencies.R
Outdated
} | ||
|
||
version <- theme_version(theme) | ||
deps_hash <- rlang::hash(htmlDependencies(as_sass(theme))) |
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.
This is probably over-thinking things. The one way that the theme could change between calls is if the Bootstrap JavaScript assets change. Taking the hash of the dependencies was intended to catch this, but we'd actually have to hash the files themselves. Not sure if it's worth it.
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.
Not hard, maybe still not worth it: 58f62cd
Currently, when a pre-compiled theme is used, we re-use
{tempdir()}/bslib-precompiled-5
but copy files from bslib to the temp directory every time the pre-compiled theme is used.This PR refactors
bs_theme_dependencies()
to pull out the core logic (either use a precompiled theme or compile the theme via Sass) into helper functions, which clarifies the flow.Then, if we've already prepared the full dependency in the temp directory, we re-use the prepared dependency on subsequent calls to
bs_theme_dependencies()
.Closes #1154. The issue seen there arises when we copy files out of the package but the package is stored with all files having read-only (400) permissions. This doesn't cause problems until
bs_theme_dependencies()
is called for a second time, where we end up trying to overwrite existing files. This is a partial fix in the sense thatnix
will still complain about being unable to remove temp files, but we can't solve that entirely from bslib anyway.