diff --git a/src/server/routes/clade_cumulus.jl b/src/server/routes/clade_cumulus.jl index f7f81706..d140cda6 100644 --- a/src/server/routes/clade_cumulus.jl +++ b/src/server/routes/clade_cumulus.jl @@ -190,6 +190,15 @@ end end @post "/api/v1/studies/{study}/runs/{run}/clade-cumulus" function(req::HTTP.Request, study::String, run::String) + try + return _clade_cumulus_post_impl(req, study, run) + catch e + @error "clade-cumulus request failed" exception = (e, catch_backtrace()) + return json_error(500, "clade_cumulus_failed", sprint(showerror, e)) + end +end + +function _clade_cumulus_post_impl(req::HTTP.Request, study::String, run::String) group = _req_group(req) err = _validate_run_request(study, run) !isnothing(err) && return err diff --git a/src/server/routes/trees.jl b/src/server/routes/trees.jl index beec713a..2d1cd348 100644 --- a/src/server/routes/trees.jl +++ b/src/server/routes/trees.jl @@ -14,8 +14,8 @@ const _TREE_MAX_BYTES = 50 * 1024 * 1024 const _VIEW_MAX_BYTES = 5 * 1024 * 1024 const _tree_view_lock = ReentrantLock() -_trees_dir(study::String) = joinpath(ServerState.projects_dir(), study, "trees") -_tree_view_path(study::String, file::String) = joinpath(_trees_dir(study), ".views", file * ".json") +_trees_dir(study::AbstractString) = joinpath(ServerState.projects_dir(), study, "trees") +_tree_view_path(study::AbstractString, file::AbstractString) = joinpath(_trees_dir(study), ".views", file * ".json") _tree_format(file::AbstractString) = endswith(lowercase(file), ".jplace") ? "jplace" : "newick" @@ -23,12 +23,12 @@ function _valid_tree_file(file::AbstractString)::Bool _valid_name(file) && any(ext -> endswith(lowercase(file), ext), _TREE_EXTENSIONS) end -function _study_exists(study::String)::Bool +function _study_exists(study::AbstractString)::Bool _valid_name(study) && (isdir(joinpath(ServerState.projects_dir(), study)) || study in _study_names()) end -function _tree_request_error(study::String, file::Union{String,Nothing}=nothing) +function _tree_request_error(study::AbstractString, file::Union{AbstractString,Nothing}=nothing) _study_exists(study) || return json_error(404, "study_not_found", "Study '$study' not found") isnothing(file) && return nothing _valid_tree_file(file) || return json_error(400, "invalid_name", @@ -36,7 +36,7 @@ function _tree_request_error(study::String, file::Union{String,Nothing}=nothing) nothing end -function _tree_listing(study::String) +function _tree_listing(study::AbstractString) dir = _trees_dir(study) isdir(dir) || return NamedTuple[] files = sort(filter(f -> _valid_tree_file(f) && isfile(joinpath(dir, f)), readdir(dir)))