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

Unable to watch directory changes via \\wsl$\ redirector #4581

Closed
throwable-one opened this issue Oct 8, 2019 · 4 comments
Closed

Unable to watch directory changes via \\wsl$\ redirector #4581

throwable-one opened this issue Oct 8, 2019 · 4 comments

Comments

@throwable-one
Copy link

It seems that FindFirstChangeNotification doesn't work

#include <Windows.h>
#include <stdio.h>

int main()
{
	const WCHAR dir[] = L"\\\\wsl$\\Ubuntu-18.04\\"; // Failed to monitor changes: 1
	const int dw_notify_filter = FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_ACTION_MODIFIED |
		FILE_ACTION_ADDED | FILE_ACTION_REMOVED;
	const HANDLE change_handle = FindFirstChangeNotification(dir,
	                                                         TRUE,
	                                                         dw_notify_filter);

	if (change_handle == INVALID_HANDLE_VALUE)
	{
		const DWORD err = GetLastError();
		printf("Failed to monitor changes %ld", err);
		return -1;
	}
	printf("OK");
	return 0;
}

@throwable-one
Copy link
Author

throwable-one commented Oct 8, 2019

.NET filewatcher accepts this path but never returns anything

    internal class MyClass
    {
        public static void Main(string[] args)
        {
           var w =  new FileSystemWatcher("\\\\wsl$\\Ubuntu-18.04\\");
           w.WaitForChanged(WatcherChangeTypes.All);
           Console.Write("Changed!");
        }
    }

@throwable-one throwable-one changed the title Unable to watch direftory changes via \\wsl$\ redirector Unable to watch directory changes via \\wsl$\ redirector Oct 8, 2019
@therealkenc
Copy link
Collaborator

therealkenc commented Oct 10, 2019

This is related to #4064 (#4224, #4169 et al). #4064 issue has a coveted bug tag, but won't dupe you because I am pretty sure Code watches from the other side not Windows (can't swear to that).

If you look at the FileFirstChangeNotification docs the scenario is supported by SMB3. But not WSL's 9p. Be mildly interesting to set up a Samba share on the Linux side and see if it takes.

Thanks for the excellent submission.

@vasekboch
Copy link

This one is crucial, when I use for example Jetbrains PHPStorm, that caches directory structure. And I update something in WSL2 (dependencies or git checkout). The PHPStorm relies on file notify to trigger cache invalidation.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants