diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e9a7b..48a0a69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] - ReleaseDate +### Fixed + +- Fix version file + ## [0.2.1] - 2025-10-28 ### Added @@ -56,8 +60,8 @@ - First release -[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.1...HEAD +[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.1...HEAD [0.2.1]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.0...v0.2.1 [0.2.0]: https://github.com/meehl/rusty-path-of-building/compare/v0.1.2...v0.2.0 [0.1.2]: https://github.com/meehl/rusty-path-of-building/compare/v0.1.1...v0.1.2 diff --git a/src/installer.rs b/src/installer.rs index 6dd0619..1f7767d 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -12,7 +12,7 @@ use flate2::read::GzDecoder; use regex::Regex; use std::{ fs::{self}, - io::{Write, copy}, + io::copy, path::{Path, PathBuf}, sync::mpsc::{self, Receiver, TryRecvError}, thread, @@ -158,6 +158,14 @@ fn install>( // Skip installation if version file exists let version_file_path = target_dir.as_ref().join("rpob.version"); if version_file_path.exists() { + let old_version = fs::read_to_string(&version_file_path).unwrap(); + let current_version = env!("CARGO_PKG_VERSION"); + + if old_version != current_version { + log::info!("New version detected: {old_version} -> {current_version}"); + fs::write(&version_file_path, current_version).unwrap(); + } + return Ok(()); } @@ -166,9 +174,7 @@ fn install>( set_branch_and_platform(&target_dir)?; // write version file - let mut version_file = fs::File::create(version_file_path)?; - let pkg_version = env!("CARGO_PKG_VERSION"); - version_file.write_all(pkg_version.as_bytes())?; + fs::write(&version_file_path, env!("CARGO_PKG_VERSION")).unwrap(); Ok(()) }