Closed starzation closed 9 months ago
Regarding this https://github.com/vinegarhq/vinegar/pull/322 and the change, it seems you're trying to copy Overlay
to dest
. Is it right?
We assume that users can check existence or properties of the root argument, the first argument the users give to cp.Copy
func, by theirselves.
OnError
or OnSymlink
is to define behavior to handle something inside the folders, not the root folders.
Therefore, if you are talking about the root folders, you should separate the check before calling cp.Copy
.
If my quick view above doesn't answer your question, let me ask you some clarification questions:
Given what 1
, what 2
do you expect?
What 3
did you see?
What 4
is your proposal?
Regarding this vinegarhq/vinegar#322 and the change, it seems you're trying to copy
Overlay
todest
. Is it right? Yes that right.
Look like this is not the lib issue right? This mean we need to check if the file is already exists first if not then we call cp.Copy
right? Since by default cp.Copy
doesn't check if the file already exists and trying to copy the file
For more information:
Overlay
and dest
is root folder and we trying to copy file inside Overlay
into dest
folder.
I think you understand it right.
In other words: as long as the user knows the names of what to be compared, the user should compare them by the user-side.
The methods "OnXxx" are provided because some cases happening during copying must be controlled by the user even the user couldn't anticipate the names of entries which would happen the cases.
Let me know if anything still unclear for you. I'm happy to hear to improve this pkg.
Thank you for your clarification. Also thank you for your assistance.
If i read copy
behavior right, copy
copies file no matter if the files exist in the destination directory, so why is the same not done for symlinks?
I expected copy
to copy files from a source directory to a destination directory recursively, no matter if files are present or not in the destination.
@apprehensions Thank you for your comment.
Out discussion point is about "root" and "children". When we talk about "root", it's users' responsibility to check the validity.
When we talk about "children" under the root, we need a basic philosophy and some options to let users control the behavior.
Why are symlinks an exception?
Clarification: Are we talking about this? https://github.com/otiai10/copy/blob/1b0f2555a418af91c68cbd6c233a15e5e771ca96/copy.go#L314-L325
Yes, it seems copying the source symlinks even if it's links to somewhere that does not exist. It would hr better if the symlinks gets copied to the destination regardless if it does not exist much like regular files
I think I got your point:
copy.Copy
should not return error even if the destination of symlink already exists. (Update the symlink as of the source)Correct me if I'm understanding wrong.
Yes, the children (destination, copy) symlink should have the same behavior as copying regular files.
I apologize if I was explaining incorrectly.
Can you please open another issue for this?
@starzation can you confirm #145 fixes your problem?
Like the tittle said if the file is already exists (in destination folder) it will throw 'symlink error file exists'
There already a quick patch in vinegarhq/vinegar#322, Should the patch belong here or theres?
Issue (For log and more info): vinegarhq/vinegar#321 Code: vinegarhq/vinegar/internal/dirs/copy.go