Skip to content

Commit

Permalink
Don't overwrite schema files that haven't changed (#49)
Browse files Browse the repository at this point in the history
* Don't overwrite schema files that haven't changed

* Add changelog
  • Loading branch information
dmoverton authored Apr 23, 2024
1 parent 992f466 commit 460b251
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ This changelog documents the changes between release versions.

## [Unreleased]
- Fix incorrect order of results for query requests with more than 10 variable sets (#37)
- In the CLI update command, don't overwrite schema files that haven't changed ([#49](https://github.com/hasura/ndc-mongodb/pull/49/files))

## [0.0.4] - 2024-04-12
- Queries that attempt to compare a column to a column in the query root table, or a related table, will now fail instead of giving the incorrect result ([#22](https://github.com/hasura/ndc-mongodb/pull/22))
Expand Down
9 changes: 8 additions & 1 deletion crates/configuration/src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@ where
{
let path = default_file_path(configuration_dir, basename);
let bytes = serde_json::to_vec_pretty(value)?;
fs::write(path.clone(), bytes)

// Don't write the file if it hasn't changed.
if let Ok(existing_bytes) = fs::read(&path).await {
if bytes == existing_bytes {
return Ok(())
}
}
fs::write(&path, bytes)
.await
.with_context(|| format!("error writing {:?}", path))
}
Expand Down

0 comments on commit 460b251

Please sign in to comment.