fix: корректная проверка схем
This commit is contained in:
@@ -1,15 +1,3 @@
|
||||
.on_load = function(ns) {
|
||||
|
||||
check_and_init_scheme()
|
||||
|
||||
# set global settings:
|
||||
set_global_options(
|
||||
shiny.host = "0.0.0.0",
|
||||
shiny.port = 1338,
|
||||
APP.DEBUG = FALSE
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
#' @export
|
||||
#' @description костыли для упрощения работы себе
|
||||
@@ -17,23 +5,6 @@ set_global_options = function(
|
||||
SYMBOL_DELIM = "; ",
|
||||
...
|
||||
) {
|
||||
|
||||
config_params_to_check <- c(
|
||||
"form_app_version",
|
||||
"form_id",
|
||||
"form_name",
|
||||
"form_app_configure_path",
|
||||
"form_auth_enabled",
|
||||
"form_schemes"
|
||||
)
|
||||
|
||||
expected_params_in_config <- config_params_to_check %in% names(config::get())
|
||||
if (!all(expected_params_in_config)) {
|
||||
cli::cli_abort(c(
|
||||
"Необходимо добавить в файл конфига {.file config.yml} следующие параметры:",
|
||||
paste0(config_params_to_check[!expected_params_in_config], ":")
|
||||
))
|
||||
}
|
||||
|
||||
options(
|
||||
SYMBOL_DELIM = SYMBOL_DELIM,
|
||||
@@ -55,6 +26,27 @@ ENABLED_SCHEMES <- stats::setNames(names(ENABLED_SCHEMES), ENABLED_SCHEMES)
|
||||
#' @export
|
||||
check_and_init_scheme = function() {
|
||||
|
||||
cli::cli_inform(c("*" = "проверка файла конфигурации..."))
|
||||
|
||||
config_params_to_check <- c(
|
||||
"form_app_version",
|
||||
"form_id",
|
||||
"form_name",
|
||||
"form_app_configure_path",
|
||||
"form_auth_enabled",
|
||||
"form_schemes"
|
||||
)
|
||||
|
||||
expected_params_in_config <- config_params_to_check %in% names(config::get())
|
||||
|
||||
if (!all(expected_params_in_config)) {
|
||||
cli::cli_abort(c(
|
||||
"Необходимо добавить в файл конфига {.file config.yml} следующие параметры:",
|
||||
paste0(config_params_to_check[!expected_params_in_config], ":")
|
||||
))
|
||||
}
|
||||
# -------------------
|
||||
|
||||
cli::cli_inform(c("*" = "проверка схемы..."))
|
||||
|
||||
options(box.path = here::here())
|
||||
@@ -81,16 +73,17 @@ check_and_init_scheme = function() {
|
||||
if (!all(file.exists(scheme_file))) {
|
||||
cli::cli_abort(c("Отсутствуют файлы схем для следующих наименований:", paste("-", names(scheme_file)[!file.exists(scheme_file)])))
|
||||
}
|
||||
|
||||
|
||||
db_files <- paste0(config::get("form_app_configure_path"), "/db/", scheme_names, ".sqlite")
|
||||
|
||||
if (!dir.exists("temp")) dir.create("temp")
|
||||
hash_file <- "temp/schema_hash.rds"
|
||||
|
||||
#
|
||||
exist_hash <- tools::md5sum(c(scheme_file, files_to_watch))
|
||||
|
||||
# если первый запуск (нет файла с кешем) инициализация схемы
|
||||
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds") | !all(file.exists(db_files))) {
|
||||
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds")) {
|
||||
|
||||
init_scheme(scheme_file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user