@@ -66,39 +66,39 @@ srv_teal_lockfile <- function(id) {
6666 shinyjs :: disable(" lockFileLink" )
6767 }
6868
69- is_lockfile_enabled <- isTRUE(getOption(" teal.lockfile.enable" ))
70- user_lockfile <- getOption(" teal.lockfile.path" , " " )
69+ shiny :: onStop(function () {
70+ if (file.exists(lockfile_path ) && ! shiny :: isRunning()) {
71+ logger :: log_debug(" Removing lockfile after shutting down the app" )
72+ file.remove(lockfile_path )
73+ }
74+ })
75+
7176 lockfile_path <- " teal_app.lock"
77+ is_lockfile_enabled <- isTRUE(getOption(" teal.lockfile.enable" ))
78+ user_lockfile_path <- getOption(" teal.lockfile.path" , default = " " )
79+ is_user_lockfile_set <- ! identical(user_lockfile_path , " " )
7280
7381 if (! is_lockfile_enabled ) {
7482 logger :: log_debug(" 'teal.lockfile.enable' option is set to false. Hiding a lockfile download button." )
7583 shinyjs :: hide(" lockFileLink" )
7684 return (NULL )
77- } else if (identical(user_lockfile , " " ) && ! .is_lockfile_deps_installed()) {
78- warning(" Automatic lockfile creation disabled. `mirai` and `renv` packages must be installed." )
79- shinyjs :: hide(" lockFileLink" )
80- return (NULL )
8185 }
8286
83- shiny :: onStop(function () {
84- if (file.exists(lockfile_path ) && ! shiny :: isRunning()) {
85- logger :: log_debug(" Removing lockfile after shutting down the app" )
86- file.remove(lockfile_path )
87- }
88- })
89-
90- # run renv::snapshot only once per app. Once calculated available for all users
9187 if (file.exists(lockfile_path )) {
92- logger :: log_debug(" Lockfile has been already created - skipping automatic creation." )
88+ logger :: log_debug(" Lockfile has already been created for this app - skipping automatic creation." )
9389 enable_lockfile_download()
9490 return (NULL )
9591 }
9692
93+ if (! is_user_lockfile_set && ! .is_lockfile_deps_installed()) {
94+ warning(" Automatic lockfile creation disabled. `mirai` and `renv` packages must be installed." )
95+ shinyjs :: hide(" lockFileLink" )
96+ return (NULL )
97+ }
9798
98- # don't run renv::snapshot when option is set
99- if (! identical(user_lockfile , " " )) {
100- if (file.exists(user_lockfile )) {
101- file.copy(user_lockfile , lockfile_path )
99+ if (is_user_lockfile_set ) {
100+ if (file.exists(user_lockfile_path )) {
101+ file.copy(user_lockfile_path , lockfile_path )
102102 logger :: log_debug(' Lockfile set using option "teal.lockfile.path" - skipping automatic creation.' )
103103 enable_lockfile_download()
104104 } else {
0 commit comments