feat: implements remaining http cache conditionals by TinyTinni · Pull Request #407 · sigoden/dufs (original) (raw)

In the second commit yesterday, I removed this code change again. There is actually no reason to separate Etag and LastModified as those both are computed by the existing file meta data information.

ETag can fail, if the file's timestamp isn't present. In this case, LastModified fails too.
Etag can also fail, if the .parse method fails when the string is ill-formated [1]. But the string is almost static except when there is no valid timestamp, in this case we fail before. (size doesn't seem to have a failure mode at seems to be guaranteed)

That was my reasoning to revert the change on this function, as it seemed unnecessary.
But it might be safer to have separate checks.

I am unsure which path to take. Going with the rolled back changes or do you want the 2 options and checks if etag could be parsed?

[1] headers crate etag parse: https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#tymethod.from_str