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

bustDirCache on FileSystemRouter.reload & fix of dir_cache keys in windows #15091

Merged
merged 32 commits into from
Nov 27, 2024

Conversation

Kapsonfire-DE
Copy link
Contributor

@Kapsonfire-DE Kapsonfire-DE commented Nov 11, 2024

What does this PR do?

When the structure of the routes directory for the FileSystemRouter changes, the reload function cant load it, because readDirInfo is cached. So I changed the code to recursively bust the dirCache.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

I dont know how to write tests for this. Ive tested it locally.

Fixes #4522

Copy link
Member

@paperdave paperdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice. at a glance this looks reasonable, but you should add a test case to cover changing directories

src/bun.js/api/filesystem_router.zig Show resolved Hide resolved
@Jarred-Sumner
Copy link
Collaborator

Can’t we bump the version number and then we don’t need to eagerly call bustDirCache?

@Kapsonfire-DE
Copy link
Contributor Author

@Electroid it seems it didnt worked, since CI still said no changed files

@Kapsonfire-DE Kapsonfire-DE changed the title bustDirCache on FileSystemRouter.reload bustDirCache on FileSystemRouter.reload & fix of dir_cache keys in windows Nov 16, 2024
@Kapsonfire-DE
Copy link
Contributor Author

The key generation for dir_caches had a bug on windows.
Trailing slashes were removed but it was hardcoded to "/" - since Windows uses "\" the bustDirCache function in Windows did not work properly. I've changed it by moving the hardcoded to a constant defined before. the constant is set on comptime.
\ for windows
else
/

Copy link
Member

@paperdave paperdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will run tests but one nitpick

src/allocators.zig Outdated Show resolved Hide resolved
@Jarred-Sumner Jarred-Sumner merged commit 1bb211d into oven-sh:main Nov 27, 2024
66 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileSystemRouter reload method not working
3 participants