Skip to content

Commit

Permalink
Fix the FileSourceParams deserialization to support URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
rdettai committed Sep 28, 2023
1 parent 29ea0d7 commit ee47ce8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions quickwit/quickwit-config/src/source_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,16 @@ pub struct FileSourceParams {
pub filepath: Option<PathBuf>, //< If None read from stdin.
}

// Deserializing a filepath string into an absolute filepath.
/// Deserializing as an URI first to validate the input.
///
/// TODO: we might want to replace `PathBuf` with `Uri` directly in
/// `FileSourceParams`
fn absolute_filepath_from_str<'de, D>(deserializer: D) -> Result<Option<PathBuf>, D::Error>
where D: Deserializer<'de> {
let filepath_opt: Option<String> = Deserialize::deserialize(deserializer)?;
if let Some(filepath) = filepath_opt {
let uri = Uri::from_str(&filepath).map_err(D::Error::custom)?;
Ok(uri.filepath().map(|path| path.to_path_buf()))
Ok(Some(PathBuf::from(uri.as_str())))
} else {
Ok(None)
}
Expand Down

0 comments on commit ee47ce8

Please sign in to comment.