Skip to content

Commit

Permalink
Allow to set work_path when archiving subject
Browse files Browse the repository at this point in the history
  • Loading branch information
dipterix committed Aug 27, 2024
1 parent 5437bc6 commit 889b2b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: raveio
Type: Package
Title: File-System Toolbox for RAVE Project
Version: 0.9.0.68
Version: 0.9.0.69
Language: en-US
Authors@R: c(
person("Zhengjia", "Wang", email = "[email protected]", role = c("aut", "cre", "cph")),
Expand Down
22 changes: 19 additions & 3 deletions R/utils-archive.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#' notes, and user-generated exports)
#' @param config a list of configurations, including changing subject code,
#' project name, or to exclude cache data; see examples
#' @param work_path temporary working path where files are copied; default is
#' temporary path. Set this variable explicitly when temporary path is
#' on external drives (for example, users have limited storage on local
#' drives and cannot hold the entire subject)
#'
#' @examples
#'
Expand Down Expand Up @@ -50,8 +54,11 @@
#'
#' @export
archive_subject <- function(
subject, path, includes = c("orignal_signals", "processed_data", "rave_imaging", "pipelines", "notes", "user_generated"),
config = list()
subject, path,
includes = c("orignal_signals", "processed_data", "rave_imaging",
"pipelines", "notes", "user_generated"),
config = list(),
work_path = NULL
) {

# DIPSAUS DEBUG START
Expand Down Expand Up @@ -105,7 +112,13 @@ archive_subject <- function(
}


root_dir <- file.path(tempdir(check = TRUE), "archive", subject$project_name, subject$subject_code, "archive")
if(length(work_path) != 1 || !is.character(work_path) || is.na(work_path) ||
!dir.exists(work_path)) {
root_dir <- file.path(tempdir(check = TRUE), "archive", subject$project_name, subject$subject_code, "archive")
} else {
root_dir <- file.path(work_path, "archive")
}

if(file.exists(root_dir)) {
unlink(root_dir, recursive = TRUE, force = TRUE)
}
Expand Down Expand Up @@ -483,6 +496,9 @@ install_subject <- function(
}
if(!dir.exists(extract_path)) {
utils::unzip(path, overwrite = TRUE, exdir = extract_path)
on.exit({
unlink(extract_path, recursive = TRUE, force = TRUE)
})
}
path <- extract_path
}
Expand Down
8 changes: 7 additions & 1 deletion man/archive_subject.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 889b2b4

Please sign in to comment.