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

fix: [DirectoryWatcher] - Folders are case sensitive on Linux #2363

Merged
merged 2 commits into from
Jul 6, 2024

Conversation

Jklawreszuk
Copy link
Collaborator

@Jklawreszuk Jklawreszuk commented Jun 28, 2024

PR Details

For some reason Path is transformed to lowercase, but on Linux distros it causes a runtime error - "The directory name .... does not exist" during game runtime.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Jklawreszuk Jklawreszuk changed the title fix: [DirectoryWatcher] - Folders are case sensitive on Unix fix: [DirectoryWatcher] - Folders are case sensitive on Linux Jun 28, 2024
@Eideren
Copy link
Collaborator

Eideren commented Jun 28, 2024

Wouldn't it make sense to remove the ToLowerInvariant call entirely ? If it works on linux it will work on windows since it is the more lenient of the two ? Or do we have some specific handling per os here that breaks this assumption ?

@IXLLEGACYIXL
Copy link
Collaborator

IXLLEGACYIXL commented Jun 28, 2024

                if (needProjectReload == false
                    && ((e.ChangeType == FileEventChangeType.Deleted || e.ChangeType == FileEventChangeType.Renamed || e.ChangeType == FileEventChangeType.Created)
                    && Path.GetExtension(changedFile)?.ToLowerInvariant() == ".cs"
                    && changedFileDirectoryName.StartsWith(directoryName, StringComparison.OrdinalIgnoreCase)))
                {
                    needProjectReload = true;
                }

would break/not work on other parts that have path comparisons

@Eideren
Copy link
Collaborator

Eideren commented Jun 28, 2024

That example would not break on windows afaict though, on linux it may if you have two directory whose name differs only in character casing. What would break on windows is string comparison without IgnoreCase specified and with one of the path somehow retrieved with a different casing than the actual path.

@IXLLEGACYIXL
Copy link
Collaborator

on linux it needs a ordinal comparison, on windows it doesnt matter

@Jklawreszuk
Copy link
Collaborator Author

What, then, do you finally suggest? I would like to avoid regression thus I added a IsLinux condition to not break anything

@Eideren
Copy link
Collaborator

Eideren commented Jul 3, 2024

Okay, probably best to leave this for later, can you add a small comment above those lines mentioning that it might be safe to remove that check but to investigate that further on windows ?

@Jklawreszuk
Copy link
Collaborator Author

Yeah, taking small steps 😅 Alright , I've added a TODO comment as you suggested.

@Eideren Eideren merged commit 93e8d3d into stride3d:master Jul 6, 2024
2 checks passed
@Eideren
Copy link
Collaborator

Eideren commented Jul 6, 2024

Thanks !

@Jklawreszuk Jklawreszuk deleted the directorywatcher branch July 6, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants