We use the hostname when creating the csv file. When using
with_extension on the path we create from the hostname it will strip
the last part after a dot as it assumes that that is the file extention.
This fixes it and just creates the filename using format. This should be fine on all platforms.
QPQ2NBVJIFSG2RVAH4WNW4KSNJ4DTJBRGPKPFHMJGWL6F573GW6AC let file_path = folder_path.join(hostname).with_extension("csv");
// Can't use .with_extension here as it will not work properly with hostnames// that contain dots. See test::dot_filename_with_extension for an// example.let file_path = folder_path.join(format!("{}.csv", hostname));
#[cfg(test)]mod test {#[test]fn dot_filename_with_extension() {let folder_path = std::path::PathBuf::from("/tmp");let hostname = "test.test.test";let expected = std::path::PathBuf::from(format!("/tmp/{}.csv", hostname));let bad = folder_path.join(hostname).with_extension("csv");let good = folder_path.join(format!("{}.csv", hostname));assert_ne!(bad, expected);assert_eq!(good, expected);}}