Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

excise dssecrets #11

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/sb_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sb_replace_files <- function(sb_id, ..., file_hash){
if (!sbtools::is_logged_in()){

sb_secret <- dssecrets::get_dssecret("cidamanager-sb-srvc-acct")
message(paste("Using the secret dated", sb_secret$timeStamp, "to log in."))
sbtools::authenticate_sb(username = sb_secret$username, password = sb_secret$password)

}
Expand Down Expand Up @@ -128,8 +129,12 @@ do_item_replace_tasks <- function(sb_id, files, sources) {
upload_and_record <- function(sb_id, filepath) {

# First verify that you are logged into SB. Need to do this for each task that calls
sb_secret_login()

if (!sbtools::is_logged_in()) {
if (suppressWarnings(suppressMessages(require(dssecrets)))) {
message("ScienceBase is not logged in. Using dssecrets to log in with the cidamanager-sb-srvc-acct secret")
sb_secret_login()
}
}
# Second, upload the file
item_replace_files(sb_id, files = filepath)

Expand All @@ -153,7 +158,13 @@ upload_and_record <- function(sb_id, filepath) {
#' or if any duplicated file names exist on sciencebase for this `sb_id`.
verify_uploads <- function(file_tbl, tgt_names, remake_file){

sb_secret_login()
# First verify that you are logged into SB. Need to do this for each task that calls
if (!sbtools::is_logged_in()) {
if (suppressWarnings(suppressMessages(require(dssecrets)))) {
message("ScienceBase is not logged in. Using dssecrets to log in with the cidamanager-sb-srvc-acct secret")
sb_secret_login()
}
}
sb_id <- unique(file_tbl$sb_id)
# this call is not robust to a tbl w/ more than one unique sb_id
stopifnot(length(sb_id) == 1)
Expand Down