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

Partial reload #3109

Merged
merged 15 commits into from
Oct 17, 2019
Merged

Partial reload #3109

merged 15 commits into from
Oct 17, 2019

Conversation

mhvsa
Copy link
Contributor

@mhvsa mhvsa commented Oct 11, 2019

fixes #2872

Copy link
Member

@bartlomieju bartlomieju left a 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"),
Copy link
Member

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)

Copy link
Contributor Author

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)")
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

Error instead of continuing

Copy link
Contributor Author

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('/') {
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@bartlomieju bartlomieju left a 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")
Copy link
Member

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

Comment on lines +180 to +181
.use_delimiter(true)
.require_equals(true)
Copy link
Member

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();
Copy link
Member

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

@mhvsa mhvsa closed this Oct 16, 2019
@mhvsa mhvsa reopened this Oct 16, 2019
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")
Copy link
Member

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.

Copy link
Member

@bartlomieju bartlomieju Oct 16, 2019

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.

Copy link
Member

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.

cli/file_fetcher.rs Outdated Show resolved Hide resolved
@@ -533,6 +538,26 @@ fn filter_shebang(bytes: Vec<u8>) -> Vec<u8> {
}
}

fn check_cache_blacklist(url: &Url, black_list: &[String]) -> bool {
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@ry ry Oct 17, 2019

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@ry
Copy link
Member

ry commented Oct 16, 2019

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`

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - nice work

@ry ry merged commit 75ec942 into denoland:master Oct 17, 2019
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.

[Feature Request] Support partial reload
3 participants