Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't overwrite schema files that haven't changed #49

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading