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

Fixes #15456: Handle ttl parameter correctly in shared-files API #2384

Merged
merged 1 commit into from
Aug 14, 2019
Merged

Fixes #15456: Handle ttl parameter correctly in shared-files API #2384

merged 1 commit into from
Aug 14, 2019

Conversation

bernsteining
Copy link
Contributor

@bernsteining
Copy link
Contributor Author

bernsteining commented Aug 13, 2019

Commit modified

removed warnings

Copy link
Member

@amousset amousset 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, could you add a test for this?

@bernsteining
Copy link
Contributor Author

Commit modified

1 similar comment
@bernsteining
Copy link
Contributor Author

Commit modified

.expect("Unable to write file");
fs::write(
format!("shared-files/{}.metadata", peek),
format!("{}expires={}\n", metadata_string, timestamp.unwrap()),
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't unwrap here, we need to properly manage the error

Copy link
Member

@amousset amousset Aug 14, 2019

Choose a reason for hiding this comment

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

I just saw it is actually correct as the error cases returns early. Could you change the definition of timestamp to something like

let timestamp = match parse_ttl(..) {
   Ok(ttl) => ttls,
   Err(_) => return StatusCode::from_u16(500).unwrap(),
}

to make it clearer?

@bernsteining
Copy link
Contributor Author

Commit modified

@@ -97,7 +97,7 @@ impl RawNodesList {
}

pub struct NodesList {
list: RawNodesList,
pub list: RawNodesList,
Copy link
Member

Choose a reason for hiding this comment

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

It should not be public, but you can add a get_... method in impl

@bernsteining
Copy link
Contributor Author

Commit modified

@@ -123,6 +123,10 @@ impl NodesList {
Ok(NodesList { list: nodes, my_id })
}

pub fn get_nodeslist(&self) -> &NodesList {
Copy link
Member

Choose a reason for hiding this comment

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

The idea of the fields not being public is to prevent code from outside of this module to rely on the internal representation of the nodes list, which may evolve. Instead you should create a dedicated method for what you are trying to to. In this case, it is even easier is it seems to already be there :)

@bernsteining
Copy link
Contributor Author

Commit modified

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit a11cb79 into Normation:master Aug 14, 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
3 participants