Skip to content

Commit 2fd459a

Browse files
author
Ryan Patrick Kyle
committed
🙈 allow reloading without assets
1 parent 0328055 commit 2fd459a

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Diff for: R/dash.R

+14-11
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ Dash <- R6::R6Class(
650650
server_on <- TRUE
651651

652652
while (server_on) {
653-
if (self$config$hot_reload == TRUE && file.exists(file.path(getAppPath(), "assets"))) {
653+
if (self$config$hot_reload == TRUE) {
654654
self$server$on('cycle-end', function(server, ...) {
655655
current_asset_modtime <- modtimeFromPath(private$assets_folder)
656656
current_root_modtime <- modtimeFromPath(getAppPath(), recursive = TRUE)
@@ -662,26 +662,29 @@ Dash <- R6::R6Class(
662662

663663
initiate_reload <- isTRUE((as.integer(Sys.time()) - private$last_reload) > self$config$hot_reload_interval)
664664

665-
if (!is.null(private$asset_modtime) && initiate_reload && (updated_assets || updated_root)) {
665+
if (!is.null(current_asset_modtime) && initiate_reload && (updated_assets || updated_root)) {
666666
# refreshAssetMap silently returns a list of updated objects in the map
667667
# we can use this to retrieve the modified files, and also determine if
668668
# any are scripts or other non-CSS data
669-
updatedFiles <- private$refreshAssetMap()
669+
has_assets <- file.exists(file.path(getAppPath(), private$assets_folder))
670670

671-
private$modified_since_reload <- updatedFiles$modified
672-
673-
private$asset_modtime <- current_asset_modtime
674-
# update the hash passed back to the renderer, and bump the timestamp
675-
# to match the current reloading event
671+
if (has_assets) {
672+
updatedFiles <- private$refreshAssetMap()
673+
private$modified_since_reload <- updatedFiles$modified
674+
private$asset_modtime <- current_asset_modtime
675+
# update the hash passed back to the renderer, and bump the timestamp
676+
# to match the current reloading event
677+
other_changed <- any(tools::file_ext(updatedFiles$modified) != "css")
678+
other_added <- any(tools::file_ext(updatedFiles$added) != "css")
679+
}
680+
676681
private$updateReloadHash()
677682
flush.console()
678683

679684
# if any filetypes other than CSS are encountered in those which
680685
# are modified or deleted, restart the server
681-
other_changed <- any(tools::file_ext(updatedFiles$modified) != "css")
682-
other_added <- any(tools::file_ext(updatedFiles$added) != "css")
683686

684-
hard_reload <- other_changed || other_added || updated_root
687+
hard_reload <- updated_root || (has_assets && other_changed || other_added)
685688

686689
if (!hard_reload) {
687690
# refresh the index but don't restart the server

0 commit comments

Comments
 (0)