-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Partial reload #3109
Partial reload #3109
Conversation
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.
Looking good, a few remarks!
fn test_cache_blacklist() { | ||
let args = vec![ | ||
String::from("http://deno.land/std"), | ||
String::from("http://github.com/example/mod.ts"), |
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.
@mhvsa please add test cases with query string (?foo=bar
) and fragment (#something
)
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.
ay, forgot about that, thank you
.min_values(0) | ||
.takes_value(true) | ||
.use_delimiter(true) | ||
.require_equals(true) | ||
.long("reload") | ||
.help("Reload source code cache (recompile TypeScript)") |
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 add note that blacklist is supported and also add long_help
with a few examples.
cache_bl.map(std::string::ToString::to_string).collect(); | ||
flags.cache_blacklist = resolve_urls(raw_cache_blacklist); | ||
debug!("cache blacklist: {:#?}", &flags.cache_blacklist); | ||
flags.reload = false; |
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.
Superficial
cli/flags.rs
Outdated
for urlstr in urls.iter() { | ||
let result = Url::from_str(urlstr); | ||
if result.is_err() { | ||
eprintln!("Bad Url: {}", urlstr); |
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.
Error instead of continuing
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.
maybe in file whitelist also in that case?
continue; | ||
} | ||
let mut full_url = String::from(result.unwrap().as_str()); | ||
if full_url.len() > 1 && full_url.ends_with('/') { |
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.
Why is this pop
needed? Can you add a comment?
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.
for prefix matching, it's the same thing as in files whitelist
it removes everything after '/' from the address, so e.g /foo/bar -> /foo
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.
Looks good! It just appeared to me that it'd be nice to support regexes as well, but that can be done in separate PR.
cli/flags.rs
Outdated
.long_help("Reload source code cache (recompile TypeScript). Supports blacklist\ | ||
--reload // Reload everything\ | ||
--reload=https://deno.land/std // Reload everything from the standard module\ | ||
--reload=https://deno.land/std/fs/utils.ts,https://deno.land/std/fmt/colors.ts // Reload only fs/utils and fmt/colors modules") |
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.
s/only fs/utils and fmt/colors modules/only fs/utils.ts and fmt/colors.ts modules
.use_delimiter(true) | ||
.require_equals(true) |
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.
Are those required? Would be nice to do --reload https://deno.land/std/fs/utils.ts https://deno.land/std/fmt/colors.ts
cli/state.rs
Outdated
@@ -221,10 +221,13 @@ impl ThreadSafeState { | |||
|
|||
let dir = deno_dir::DenoDir::new(custom_root)?; | |||
|
|||
let cache_bl = flags.cache_blacklist.clone(); |
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.
Superficial, just do the clone inline
cli/flags.rs
Outdated
--reload=https://deno.land/std | ||
Reload everything from the standard module | ||
--reload=https://deno.land/std/fs/utils.ts,https://deno.land/std/fmt/colors.ts | ||
Reloads only fs/utils and fmt/colors modules") |
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.
Shouldn't this be a "whitelist" rather than a "blacklist" ?
Also I don't think it's useful to say "Supports blacklist" or "Supports whitelist" - the examples you give are sufficient.
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.
That's actually a cache blacklist - urls passed to --reload
will be forced to redownloaded and recompile.
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.
Ah right. I think "blacklist" makes sense elsewhere in the code, but not here in the user facing docs.
@@ -533,6 +538,26 @@ fn filter_shebang(bytes: Vec<u8>) -> Vec<u8> { | |||
} | |||
} | |||
|
|||
fn check_cache_blacklist(url: &Url, black_list: &[String]) -> bool { |
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.
Should the black_list
argument be a Vec<Url>
instead?
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.
we never utilize any of the Url
properties by elements in the list, so I thought that maybe strings would be better (as in --allow-read whitelist)
but I agree that Vec<Url>
would be more clean, and parsing few urls wouldn't harm performance
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.
Yea, I guess it's not a big deal.
I'm ready to land this patch.... but maybe you could add a short description of this feature to the website/manual.md somewhere? I think a sentence or two would do it in the section where --reload is described.
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.
Sure
Nice patch - thanks! Just a few comments... |
a comma to separate URLs | ||
|
||
`--reload=https://deno.land/std/fs/utils.ts,https://deno.land/std/fmt/colors.ts` | ||
|
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.
Thanks!
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.
LGTM - nice work
fixes #2872