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

osf_upload conflicts = "overwrite" doesn't seem to overwrite? #130

Open
mcfrank opened this issue Aug 25, 2020 · 6 comments
Open

osf_upload conflicts = "overwrite" doesn't seem to overwrite? #130

mcfrank opened this issue Aug 25, 2020 · 6 comments

Comments

@mcfrank
Copy link

mcfrank commented Aug 25, 2020

Hi all, thanks for the osfr package!

I'm struggling a bit with the osf_upload function. In particular, the overwrite settings aren't working for me. Here's the relevant code. Here's a MWE (minus the specific project, but hopefully that's OK). A side note, the function documentation gives overwrite = TRUE in the example and that doesn't exist.

> system("touch foo")
> project %>% osf_upload("foo")
# A tibble: 1 x 3
  name  id                       meta            
  <chr> <chr>                    <list>          
1 foo   5f455498746a81028a1a33b1 <named list [3]>
> project %>% osf_upload("foo")
Error: Cannot complete action: file or folder "foo" already exists in this location
       HTTP status code 409.
> project %>% osf_upload("foo", conflicts = "overwrite")
Error: Cannot complete action: file or folder "foo" already exists in this location
       HTTP status code 409.
> project %>% osf_upload("foo", overwrite = TRUE)
Error in osf_upload(., "foo", overwrite = TRUE) : 
  unused argument (overwrite = TRUE)

Apologies if I'm missing something here!

@aaronwolen
Copy link
Member

You're right that osf_upload()'s docs include an outdated reference to the now deprecated overwrite = TRUE argument. I'll get that fixed! Thanks for reporting.

As to the error, could you check what version you're using? The following works for me with the current release (v0.2.8):

library(osfr)
#> Automatically registered OSF personal access token
project <- osf_create_project("test")

system("touch foo")
project %>% osf_upload("foo")
#> # A tibble: 1 x 3
#>   name  id                       meta            
#>   <chr> <chr>                    <list>          
#> 1 foo   5f45b2fbd4c603002e1fd3b8 <named list [3]>

project %>% osf_upload("foo")
#> Error: Can't upload file 'foo'.
#>   * A file with the same name already exists at the destination.
#>   * Use the `conflicts` argument to avoid this error in the future.

project %>% osf_upload("foo", conflicts = "overwrite")
#> # A tibble: 1 x 3
#>   name  id                       meta            
#>   <chr> <chr>                    <list>          
#> 1 foo   5f45b2fbd4c603002e1fd3b8 <named list [3]>

Created on 2020-08-25 by the reprex package (v0.3.0)

@mcfrank
Copy link
Author

mcfrank commented Aug 26, 2020 via email

@aaronwolen
Copy link
Member

Thanks, that helps! Looks like you're the latest victim of this bug which is now fixed in the master branch. If you install the latest dev version

remotes::install_github("ropensci/osfr")

you should be good to go—but please let me know if it doesn't work.

@mcfrank
Copy link
Author

mcfrank commented Aug 27, 2020 via email

@steffilazerte
Copy link
Member

I'm not sure if I should open a new issue or not, but while the previous fix works find for regular sub directories, I have this problem on "sub sub" directories.

Here is a reprex based on the last one, you can see that there are no problems with the sub directory, but the sub sub fails.

library(osfr)
#> Automatically registered OSF personal access token
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
  
# SETUP
project <- osf_create_project("test")

project %>%
  osf_mkdir("test_subdir") %>%
  osf_mkdir("test_sub_subdir")
#> # A tibble: 1 x 3
#>   name            id                       meta            
#>   <chr>           <chr>                    <list>          
#> 1 test_sub_subdir 5fb6bd5f5502ac032c8c9199 <named list [3]>

project_subdir <- project %>%
  osf_ls_files() %>%
  filter(name == "test_subdir")

project_sub_subdir <- project %>%
  osf_ls_files() %>%
  filter(name == "test_subdir") %>%
  osf_ls_files() %>%
  filter(name == "test_sub_subdir")

system("touch foo")

# TESTING SUB DIRECTORY (No problems)
project_subdir %>% osf_upload("foo")
#> # A tibble: 1 x 3
#>   name  id                       meta            
#>   <chr> <chr>                    <list>          
#> 1 foo   5fb6bd64def8eb0338e7b3c1 <named list [3]>
project_subdir %>% osf_upload("foo")
#> Error: Can't upload file 'foo'.
#>   * A file with the same name already exists at the destination.
#>   * Use the `conflicts` argument to avoid this error in the future.
project_subdir %>% osf_upload("foo", conflicts = "overwrite")
#> # A tibble: 1 x 3
#>   name  id                       meta            
#>   <chr> <chr>                    <list>          
#> 1 foo   5fb6bd64def8eb0338e7b3c1 <named list [3]>

# TESTING SUB SUB DIRECTORY (409 error)
project_sub_subdir %>% osf_upload("foo")
#> # A tibble: 1 x 3
#>   name  id                       meta            
#>   <chr> <chr>                    <list>          
#> 1 foo   5fb6bd6edef8eb0338e7b3df <named list [3]>
project_sub_subdir %>% osf_upload("foo")
#> Error: Cannot complete action: file or folder "foo" already exists in this location
#>        HTTP status code 409.
project_sub_subdir %>% osf_upload("foo", conflicts = "overwrite")
#> Error: Cannot complete action: file or folder "foo" already exists in this location
#>        HTTP status code 409.

Created on 2020-11-19 by the reprex package (v0.3.0)

@LukasWallrich
Copy link

I am now facing a different version of this issue: In the sub-subdirectory case, I do not get an error - instead, no conflicting files are found and the 'new' file is uploaded successfully - but then, the new version does not show up anywhere. Is there any workaround?

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

4 participants