You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The results of a second execution of dir_copy() when overwrite = F are not as I expected. I expected an error message, but instead it copied the source directory into the target, but nested one level deeper than during the first execution.
Here's an example
library(fs)
# create test source directory
dir_create("a/b")
file_create("a/b/test.txt")
dir_tree("a")
# a# └── b# └── test.txt# first copy: contents of 'a' are copied to 'c' = c/b/test.txt# this is what I expected
dir_copy("a", "c", overwrite=F)
dir_tree("c")
# c# └── b# └── test.txt# second copy: 'a' and it's contents are copied to 'c' = c/a/b/test.txt# expected: error about overwriting# this is the step that seems incorrect to me
dir_copy("a", "c", overwrite=F)
dir_tree("c")
# c# ├── a# │ └── b# │ └── test.txt# └── b# └── test.txt# third copy: error about overwriting
dir_copy("a", "c", overwrite=F)
# Error: [EEXIST] Failed to copy 'a/b/test.txt' to 'c/a/b/test.txt': file already exists# test with overwrite = T# first copy - same results as before: d/b/test.txt
dir_copy("a", "d", overwrite=T)
dir_tree("d")
# d# └── b# └── test.txt# second copy - expected results: silent overwrite
dir_copy("a", "d", overwrite=T)
dir_tree("d")
# d# └── b# └── test.txt# cleanup
dir_delete("a")
dir_delete("c")
dir_delete("d")
The text was updated successfully, but these errors were encountered:
I am afraid that this is how copying usually works. If the target is an existing directory, then it copied everything inside the directory. E.g. the command line cp:
The results of a second execution of
dir_copy()
whenoverwrite = F
are not as I expected. I expected an error message, but instead it copied the source directory into the target, but nested one level deeper than during the first execution.Here's an example
The text was updated successfully, but these errors were encountered: