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

Should ?drive_upload:overwrite mention drive_put? #448

Open
MichaelChirico opened this issue Oct 17, 2023 · 1 comment
Open

Should ?drive_upload:overwrite mention drive_put? #448

MichaelChirico opened this issue Oct 17, 2023 · 1 comment

Comments

@MichaelChirico
Copy link
Contributor

I am trying to write a script that saves a plot to drive; of course with plots, small tweaks are part & parcel of the job.

That means drive_upload() is probably inappropriate for my use case, though I'm accustomed to using it as my default go-to function so I'm most used to it.

Thus my journey to discovering drive_put():

  1. Use drive_upload() [implicitly using the overwrite=NA default]. Oh crap, the re-run just created a new file with the same! Is there an overwrite parameter I should be using?
  2. Glance at ?drive_upload. Yes! OK Let's try overwrite=TRUE.
  3. Looks good! Let's share this file. [Add the right permissions]. Oh crap, the re-run creates a new drive ID... which means the permissions I so painstakingly added were lost! Is that expected behavior?
  4. [Actually read overwrite carefully this time]. Oh, that's unfortunate... do I have to wait until the plot is finalized to set the permissions, then, to avoid this toil? That's unfortunate. Is it not possible to transfer the permissions over?
  5. [Check the Google Drive API... Check the {googledrive} issue tracker... Happen to see drive_update() mentioned for the first time] Oh, I guess I should be using drive_update()... but what about the initial upload? Oh, ?drive_update() mentions drive_put().

I've only just now noticed that drive_put() is mentioned at the top of ?drive_upload, oops :)

All this to say, is there any downside to adding another mention of drive_update() and/or drive_put() under the description of overwrite?

#' * `TRUE`: Check for a pre-existing file at the filepath. If there is
#' zero or one, move a pre-existing file to the trash, then carry on. Note
#' that the new file does not inherit any properties from the old one, such
#' as sharing or publishing settings. It will have a new file ID. An error is
#' thrown if two or more pre-existing files are found.

e.g.

...Note that the new file does not inherit any properties from the old one, such as sharing or publishing settings. It will have a new file ID. If you need to keep permissions and the file ID, use [drive_update()] or [drive_put()]. An error is thrown if two or more pre-existing files are found.

@MichaelChirico
Copy link
Contributor Author

Another thought: It might help beginners to see drive_update()/drive_put() mentioned in this output too?

if (overwrite && single_file(hits)) {
return(drive_trash(hits))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant