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: cache paths on Windows are broken #2760

Merged
merged 15 commits into from
Aug 11, 2019

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Aug 10, 2019

Cache paths are not properly generated on Windows.

It's broken since v0.13.0.

Ref:
denoland/std#552
denoland/std#556

Example:

file:///C:/deno/js/unit_test_runner.ts
// for above URL this cache path should be generated 
file\c\deno\js\unit_test_runner.ts
// this is produced (probably)
C:/deno/js/unit_test_runner.ts

@bartlomieju bartlomieju changed the title fix: cache path for Windows fix: cache paths on Windows are broken Aug 10, 2019
@bartlomieju
Copy link
Member Author

@piscisaureus I think I managed to make it work. We're gonna need to do a release with this change to fix CI in standard lib

let disk = (disk_byte as char).to_string();
out.push(disk);
}
_ => {}
Copy link
Member

Choose a reason for hiding this comment

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

Add an unreachable() here. Let's not silently discard part components.

Copy link
Member Author

Choose a reason for hiding this comment

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

@piscisaureus
Copy link
Member

This fixes a very acute problem, so I'm all for landing this.
However, we have similar problems with other path components, which can also contain illegal characters (e.g. ? and &).

Tangentially related, there's also a correctness issue w.r.t. case sensitivity. In URLs the path and query component are case sensitive, while the protocol and host are not. When deno_dir lives on a case insensitive file system it won't be able to handle that properly.

@bartlomieju
Copy link
Member Author

However, we have similar problems with other path components, which can also contain illegal characters (e.g. ? and &).

Haven't thought about it, but I believe Url won't return them from path_segments method. That inherently means that http://example.com/a.js?foo would be cached as http/example.com/a.js.

Tangentially related, there's also a correctness issue w.r.t. case sensitivity. In URLs the path and query component are case sensitive, while the protocol and host are not. When deno_dir lives on a case insensitive file system it won't be able to handle that properly.

Agreed, any ideas how to tackle that? Cast all protocols and hostnames to lowercase?

@piscisaureus
Copy link
Member

Haven't thought about it, but I believe Url won't return them from path_segments method. That inherently means that http://example.com/a.js?foo would be cached as http/example.com/a.js.

That doesn't seem right either. Only the part after # can be safely discarded.

@bartlomieju
Copy link
Member Author

That doesn't seem right either. Only the part after # can be safely discarded.

Agreed, shall I open a new issue with two described edge cases and we can land this patch?

@piscisaureus piscisaureus merged commit 54982e9 into denoland:master Aug 11, 2019
@bartlomieju bartlomieju deleted the fix-cache_path_for_windows branch August 12, 2019 08:03
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.

2 participants