-
Notifications
You must be signed in to change notification settings - Fork 71
Don't follow symlinks when creating a DirectoryWatcher. #2167
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
## 2.0.0 | ||
|
||
- Changes the behavior of the `DirectoryWatcher` so that it no longer follows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would make sense to also mention the bug fix aspect of the change Bug fix: fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
symlinks. On Linux, but not on MacOS or Windows, it used to watch directories | ||
to which there was a symlink within the directory being watched. It no longer | ||
does that. Code that depends on that behavior will need to be updated so that | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer people let us know if that is what they wanted, since we already have most of the implementation and could add it back. So maybe
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
it independently traverses the root directory, locating and resolving | ||
symlinks, and watching any directories being linked to. | ||
|
||
## 1.1.3 | ||
|
||
- Improve handling of | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,4 +341,19 @@ void sharedTests() { | |
await inAnyOrder(events); | ||
}); | ||
}); | ||
group('symlinks', () { | ||
test('are not watched when not enabled', () async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the name? There is no longer a choice whether to enable watching symlinks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
writeFile('dir/sub/a.txt', contents: 'a'); | ||
writeFile('sibling/sub/b.txt', contents: '1'); | ||
writeSymlink('dir/linked', target: 'sibling'); | ||
await startWatcher(path: 'dir'); | ||
|
||
writeFile('sibling/sub/b.txt', contents: '2'); | ||
// Ensure that any events for the first modification arrive before the | ||
// events for the second modification. | ||
await pumpEventQueue(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment that there is expected to be no modification event for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment added. I don't know whether the test actually confirms that. It kind of looks like it's just expecting that there's a modify event for |
||
writeFile('dir/sub/a.txt', contents: 'a'); | ||
await expectModifyEvent('dir/sub/a.txt'); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would also be interesting to test whether the process of creating or deleting a symlink inside a watched directory fires a notification. I would expect it to, and it might be worth pinning that down. But it's not essential for this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that should be tested and described with this release, since if there are any inconsistencies we might need another breaking release to fix them. One possible behaviour is that within a watched directory, changes to symlinks to files/directories are reported exactly as changes to files would be. Another possible behaviour is that they are always ignored. I think either one is fine, as long as it is consistent across all three platforms + documented. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a test. |
||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,6 +267,19 @@ void renameDir(String from, String to) { | |
void deleteDir(String path) { | ||
Directory(p.join(d.sandbox, path)).deleteSync(recursive: true); | ||
} | ||
|
||
/// Schedules writing a symlink in the sandbox at [path] that links to [target]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "schedules" refers to tracking of modification times which is not done here. Possibly it should be if we also test behaviour of symlinking files. If not then "Schedules writing" can be replaced with just "Writes". |
||
void writeSymlink(String path, {required String target}) { | ||
var fullPath = p.join(d.sandbox, path); | ||
|
||
// Create any needed subdirectories. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be just
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right. I didn't do that because I was copying the pattern in |
||
var dir = Directory(p.dirname(fullPath)); | ||
if (!dir.existsSync()) { | ||
dir.createSync(recursive: true); | ||
} | ||
|
||
Link(fullPath).createSync(target); | ||
} | ||
|
||
/// Runs [callback] with every permutation of non-negative numbers for each | ||
/// argument less than [limit]. | ||
|
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.
Please also describe how symlinks are handled in the
DirectoryWatcher
dartdoc.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.
Done