Some aspects of googledrive behaviour can be controlled via an option.

local_drive_quiet(env = parent.frame())

with_drive_quiet(code)

Arguments

env

The environment to use for scoping

code

Code to execute quietly

Auth

Read about googledrive's main auth function, drive_auth(). It is powered by the gargle package, which consults several options:

Messages

The googledrive_quiet option can be used to suppress messages from googledrive. By default, googledrive always messages, i.e. it is not quiet.

Set googledrive_quiet to TRUE to suppress messages, by one of these means, in order of decreasing scope:

  • Put options(googledrive_quiet = TRUE) in a start-up file, such as .Rprofile, or at the top of your R script

  • Use local_drive_quiet() to silence googledrive in a specific scope

    foo <- function() {
      ...
      local_drive_quiet()
      drive_this(...)
      drive_that(...)
      ...
    }
    
  • Use with_drive_quiet() to run a small bit of code silently

    with_drive_quiet(
      drive_something(...)
    )
    

local_drive_quiet() and with_drive_quiet() follow the conventions of the the withr package (https://withr.r-lib.org).

Examples

if (drive_has_token()) {
  # message: "Created Drive file"
  (x <- drive_create("drive-quiet-demo", type = "document"))

  # message: "File updated"
  x <- drive_update(x, starred = TRUE)
  purrr::pluck(x, "drive_resource", 1, "starred")

  # suppress messages for a small amount of code
  with_drive_quiet(
    x <- drive_update(x, name = "drive-quiet-works")
  )
  x$name

  # message: "File updated"
  x <- drive_update(x, media = drive_example("chicken.txt"))

  # suppress messages within a specific scope, e.g. function
  unstar <- function(y) {
    local_drive_quiet()
    drive_update(y, starred = FALSE)
  }
  x <- unstar(x)
  purrr::pluck(x, "drive_resource", 1, "starred")

  # clean up
  drive_trash(x)
  rm(unstar)
}
#> Created Drive file:
#>  drive-quiet-demo <id: 1BM_AEYTiTV2PPcGst4tRulYv0yJf36FcdREYF_6_E5I>
#> With MIME type:
#>  application/vnd.google-apps.document
#> File updated:
#>  drive-quiet-demo <id: 1BM_AEYTiTV2PPcGst4tRulYv0yJf36FcdREYF_6_E5I>
#> File updated:
#>  drive-quiet-works <id: 1BM_AEYTiTV2PPcGst4tRulYv0yJf36FcdREYF_6_E5I>
#> File trashed:
#>  drive-quiet-works <id: 1BM_AEYTiTV2PPcGst4tRulYv0yJf36FcdREYF_6_E5I>