Skip to content

Commit

Permalink
Fix folder creation by gdrive_mkdir() (#819)
Browse files Browse the repository at this point in the history
* Fix `gdrive_mkdir()' (#818)

* Update NEWS

---------

Co-authored-by: Julia Silge <[email protected]>
  • Loading branch information
UchidaMizuki and juliasilge authored Jan 13, 2024
1 parent 62a32f5 commit b8827ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

* Fixed a bug in how pins with the same name but different owners on Posit Connect were identified (#808).

* Fixed a bug in handling folders with duplicate names for Google Drive (#819, @UchidaMizuki)

# pins 1.3.0

## Breaking changes
Expand Down
18 changes: 8 additions & 10 deletions R/board_gdrive.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,8 @@ pin_store.pins_board_gdrive <- function(board, name, paths, metadata,
check_pin_name(name)
version <- version_setup(board, name, version_name(metadata), versioned = versioned)

gdrive_mkdir(board$dribble$name, name)
gdrive_mkdir(fs::path(board$dribble$name, name), version)

version_dir <- fs::path(name, version)
version_dir_dribble = googledrive::as_dribble(version_dir)
dir_dribble <- gdrive_mkdir(board$dribble, name)
version_dir_dribble <- gdrive_mkdir(dir_dribble, version)

# Upload metadata
temp_file <- withr::local_tempfile()
Expand Down Expand Up @@ -211,10 +208,11 @@ gdrive_download <- function(board, key) {
path
}

gdrive_mkdir <- function(dir, name) {
dribble <- googledrive::as_dribble(fs::path(dir, name))
if (googledrive::no_file(dribble) || !googledrive::is_folder(dribble)) {
googledrive::drive_mkdir(name, dir, overwrite = FALSE)
gdrive_mkdir <- function(dribble, name) {
dir_dribble <- googledrive::drive_ls(dribble, type = "folder")
dir_dribble <- dir_dribble[dir_dribble$name == name,]
if (googledrive::no_file(dir_dribble)) {
dir_dribble <- googledrive::drive_mkdir(name, dribble, overwrite = FALSE)
}
invisible()
invisible(dir_dribble)
}

0 comments on commit b8827ac

Please sign in to comment.