Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix folder creation by gdrive_mkdir() #819

Merged
merged 2 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
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
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)
}