fix(config): harden sync_directory async signature across platforms
This commit is contained in:
parent
654f822430
commit
bbaf55eb3b
1 changed files with 28 additions and 12 deletions
|
|
@ -3528,20 +3528,23 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
async fn sync_directory(path: &Path) -> Result<()> {
|
async fn sync_directory(path: &Path) -> Result<()> {
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
let dir = File::open(path)
|
let dir = File::open(path)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("Failed to open directory for fsync: {}", path.display()))?;
|
.with_context(|| format!("Failed to open directory for fsync: {}", path.display()))?;
|
||||||
dir.sync_all()
|
dir.sync_all()
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("Failed to fsync directory metadata: {}", path.display()))?;
|
.with_context(|| format!("Failed to fsync directory metadata: {}", path.display()))?;
|
||||||
Ok(())
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
async fn sync_directory(_path: &Path) -> Result<()> {
|
{
|
||||||
|
let _ = path;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
@ -3898,6 +3901,19 @@ tool_dispatcher = "xml"
|
||||||
assert_eq!(parsed.agent.tool_dispatcher, "xml");
|
assert_eq!(parsed.agent.tool_dispatcher, "xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn sync_directory_handles_existing_directory() {
|
||||||
|
let dir = std::env::temp_dir().join(format!(
|
||||||
|
"zeroclaw_test_sync_directory_{}",
|
||||||
|
uuid::Uuid::new_v4()
|
||||||
|
));
|
||||||
|
fs::create_dir_all(&dir).await.unwrap();
|
||||||
|
|
||||||
|
sync_directory(&dir).await.unwrap();
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&dir).await;
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn config_save_and_load_tmpdir() {
|
async fn config_save_and_load_tmpdir() {
|
||||||
let dir = std::env::temp_dir().join("zeroclaw_test_config");
|
let dir = std::env::temp_dir().join("zeroclaw_test_config");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue