Make version constants u32

This commit is contained in:
Louis Dureuil 2025-04-24 14:17:12 +02:00
parent 29b947ee43
commit 49add50cb3
No known key found for this signature in database
12 changed files with 46 additions and 70 deletions

View file

@ -272,9 +272,9 @@ impl KindWithContent {
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: (from.0, from.1, from.2),
to: (
versioning::VERSION_MAJOR.parse().unwrap(),
versioning::VERSION_MINOR.parse().unwrap(),
versioning::VERSION_PATCH.parse().unwrap(),
versioning::VERSION_MAJOR,
versioning::VERSION_MINOR,
versioning::VERSION_PATCH,
),
}),
}
@ -338,9 +338,9 @@ impl KindWithContent {
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: *from,
to: (
versioning::VERSION_MAJOR.parse().unwrap(),
versioning::VERSION_MINOR.parse().unwrap(),
versioning::VERSION_PATCH.parse().unwrap(),
versioning::VERSION_MAJOR,
versioning::VERSION_MINOR,
versioning::VERSION_PATCH,
),
}),
}
@ -386,9 +386,9 @@ impl From<&KindWithContent> for Option<Details> {
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: *from,
to: (
versioning::VERSION_MAJOR.parse().unwrap(),
versioning::VERSION_MINOR.parse().unwrap(),
versioning::VERSION_PATCH.parse().unwrap(),
versioning::VERSION_MAJOR,
versioning::VERSION_MINOR,
versioning::VERSION_PATCH,
),
}),
}

View file

@ -8,9 +8,7 @@ use tempfile::NamedTempFile;
/// The name of the file that contains the version of the database.
pub const VERSION_FILE_NAME: &str = "VERSION";
pub static VERSION_MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR");
pub static VERSION_MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
pub static VERSION_PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
pub use milli::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH};
/// Persists the version of the current Meilisearch binary to a VERSION file
pub fn create_current_version_file(db_path: &Path) -> anyhow::Result<()> {
@ -19,9 +17,9 @@ pub fn create_current_version_file(db_path: &Path) -> anyhow::Result<()> {
pub fn create_version_file(
db_path: &Path,
major: &str,
minor: &str,
patch: &str,
major: u32,
minor: u32,
patch: u32,
) -> anyhow::Result<()> {
let version_path = db_path.join(VERSION_FILE_NAME);
// In order to persist the file later we must create it in the `data.ms` and not in `/tmp`