Skip to content

gs_rsync creates a local directory when destination is google storage #172

@zamorarr

Description

@zamorarr

When using gs_rsync to upload a local source folder to a cloud destination folder, an empty local directory is created with the name of the cloud folder.

Reproducible Example

# local source data to upload
dir.create("tmp")
file.create("tmp/hello.txt")

# cloud destination
mybucket <- "gs://your-bucket-here"
gs_rsync("tmp", mybucket)

# now there is a nested local directory at gs:/<mybucket> !
utils::file_test("-d", mybucket)

Error Location
The error is coming from this line

 if (!utils::file_test("-d", destination))
    dir.create(destination, recursive = TRUE)

Proposed Solution
I believe a simple fix would be to test if the destination is a Google Storage URI.

  if (!is_gs_uri(destination) & !utils::file_test("-d", destination)) {
    dir.create(destination, recursive = TRUE)
  }

I can submit a PR if needed. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions