Skip to content

Commit

Permalink
Fix how board_gdrive() uses dribble components
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Sep 6, 2023
1 parent e70b02e commit 338802f
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions R/board_gdrive.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,39 @@ pin_list.pins_board_gdrive <- function(board, ...) {

#' @export
pin_exists.pins_board_gdrive <- function(board, name, ...) {
all_names <- googledrive::drive_ls(board$dribble$name)$name
all_names <- googledrive::drive_ls(board$dribble)$name
name %in% all_names
}

#' @export
pin_delete.pins_board_gdrive <- function(board, names, ...) {
for (name in names) {
check_pin_exists(board, name)
gdrive_delete_dir(board, name)
dribble <- googledrive::drive_ls(board$dribble)
dribble <- dribble[dribble$name == name,]
googledrive::drive_trash(dribble)
invisible()
}
invisible(board)
}

#' @export
pin_version_delete.pins_board_gdrive <- function(board, name, version, ...) {
gdrive_delete_dir(board, fs::path(name, version))
check_pin_exists(board, name)
pin_dribble <- googledrive::drive_ls(board$dribble)
pin_dribble <- pin_dribble[pin_dribble$name == name,]
version_dribble <- googledrive::drive_ls(pin_dribble)
version_dribble <- version_dribble[version_dribble$name == version,]
googledrive::drive_trash(version_dribble)
invisible()
}

#' @export
pin_versions.pins_board_gdrive <- function(board, name, ...) {
check_pin_exists(board, name)
path <- fs::path(board$dribble$path, name)
dribble <- googledrive::drive_ls(board$dribble)
dribble <- dribble[dribble$name == name,]
path <- googledrive::as_dribble(dribble)
version_from_path(sort(googledrive::drive_ls(path)$name))
}

Expand Down Expand Up @@ -185,12 +196,6 @@ gdrive_file_exists <- function(board, name) {
name %in% all_names$name
}

gdrive_delete_dir <- function(board, dir) {
path <- fs::path(board$dribble$path, dir)
googledrive::drive_trash(path)
invisible()
}

gdrive_download <- function(board, key) {
path <- fs::path(board$cache, key)
if (!fs::file_exists(path)) {
Expand Down

0 comments on commit 338802f

Please sign in to comment.