-
Notifications
You must be signed in to change notification settings - Fork 34
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
[io] copyPath/copyPathSync: expose parameter followLinks
#1267
base: main
Are you sure you want to change the base?
Conversation
FYI: @natebosch |
@jakemac53 I think uses are unlike to break if we change the default behavior. We already have a default behavior for |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
|
The current behavior is I vote to keep the current behavior as the default since this is a core function and could be used by multiple third-party projects that might not catch any changes in this behavior in their tests, as it's not a common thing to test. The main purpose is to add an extra option for those who really want to change the behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me
After a discussion with a few folks I do think it'll be easier to change the default behavior than to add an argument for this. I'm pretty confident it's the behavior we'd want as default, and omitting the argument will save on testing surface area. I'll open up another PR shortly to do that change. |
I am not quite understanding why we want to change behavior here? Why do we want to diverge from what dart:io does by default? |
I guess the question really here is do you actually copy the (recursive) file contents the links point to or do you copy the links themselves? Today we copy the file contents because by default links are followed. Both seem useful depending on the application - I would probably consider the deep copy to be the "safest" option. You are expecting a copy here and not a pointer (link). If you don't do the deep copy, and the thing the link points to changes, your "copy" actually changes too because all you copied was the pointer. |
IMHO, you shouldn't change this behavior after 8 years.
To avoid testing on the Dart SDK, you could potentially break many third-party tests. Personally, I can't agree with that. Without the
|
The intention at the time was that the links would be copied. That's also the behavior that makes the most sense to me, and is what I'd do if I was implementing this today - either being the default if there was a reason to make this optional, or more likely make it the only implementation.
Primarily:
|
See #1972 for the alternative. |
Thinking about it more, if both behaviors were necessary I think I'd still push back against the boolean argument. They feel enough like different operations to me that I'd argue for separating |
I vote for |
I mean that I'd write an entirely separate method |
Well, it's an alternative, but you are still changing the behavior of |
@jakemac53 I think the |
File(p.join(d.sandbox, _copyDir, linkSource, linkContent)); | ||
expect(await expectedDir.exists(), isTrue); | ||
expect(await expectedFile.exists(), isTrue); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for the copied content before overwrite it.
File(p.join(d.sandbox, _copyDir, linkSource, linkContent)); | ||
expect(await expectedDir.exists(), isTrue); | ||
expect(await expectedFile.exists(), isTrue); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same check here, before content overwrite.
I prefer the parameter name I have made two comments in the test code. |
followLinks
followLinks
Directory.listSync only returns Link entries if followLinks: false is passed.
copyPath needs a followLinks parameter to configure the call of Directory.listSync and allow the copy of Link entries, as expected by line else if (file is Link) {