From 2ec0affac6abddcbe19ac3f7dff0987f1ffa03cd Mon Sep 17 00:00:00 2001 From: Ho 229 Date: Sun, 15 Dec 2024 21:27:49 +0800 Subject: [PATCH] fix(integrations/cloud_filter): use explicit `stat` instead of `Entry::metadata` in `fetch_placeholders` (#5416) * fix: use explicit `stat` instead of `Entry::metadata` in `fetch_placeholders` * fix: clippy --- integrations/cloud_filter/src/lib.rs | 2 +- integrations/cloud_filter/tests/behavior/fetch_data.rs | 4 ++-- integrations/cloud_filter/tests/behavior/utils.rs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/integrations/cloud_filter/src/lib.rs b/integrations/cloud_filter/src/lib.rs index 24ace0324144..11a34edcc412 100644 --- a/integrations/cloud_filter/src/lib.rs +++ b/integrations/cloud_filter/src/lib.rs @@ -216,7 +216,7 @@ impl Filter for CloudFilter { })? .filter_map(|e| async { let entry = e.ok()?; - let metadata = entry.metadata(); + let metadata = self.op.stat(entry.path()).await.ok()?; let entry_remote_path = PathBuf::from(entry.path()); let relative_path = entry_remote_path .strip_prefix(&remote_path) diff --git a/integrations/cloud_filter/tests/behavior/fetch_data.rs b/integrations/cloud_filter/tests/behavior/fetch_data.rs index 739c2736bd58..46a65d6edfad 100644 --- a/integrations/cloud_filter/tests/behavior/fetch_data.rs +++ b/integrations/cloud_filter/tests/behavior/fetch_data.rs @@ -43,8 +43,8 @@ pub fn test_fetch_data() -> Result<(), Failed> { assert_eq!( expected_content, - file_content(&path).expect("file hash"), - "file hash", + file_content(&path).expect("file content"), + "file content", ) } Ok(()) diff --git a/integrations/cloud_filter/tests/behavior/utils.rs b/integrations/cloud_filter/tests/behavior/utils.rs index 105cc4064d87..7f617ec3850b 100644 --- a/integrations/cloud_filter/tests/behavior/utils.rs +++ b/integrations/cloud_filter/tests/behavior/utils.rs @@ -35,7 +35,8 @@ pub fn file_content(path: impl Display) -> anyhow::Result { let content = powershell_script::run(&format!("Get-Content \"{path}\"")) .context("run powershell")? .stdout() - .unwrap_or_default(); + .unwrap_or_default() + .replace("\r\n", "\n"); // powershell returns CRLF, but the fixtures use LF Ok(content) }