Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
fix .version file being created in the wrong directory (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma authored Aug 25, 2023
1 parent 3edfbcc commit dfb5b69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sqld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@ fn init_version_file(db_path: &Path) -> anyhow::Result<()> {
return Ok(());
}

let version_path = db_path.join("dbs").join(".version");
let version_path = db_path.join(".version");
if !version_path.exists() {
std::fs::create_dir_all(db_path.join("dbs"))?;
std::fs::create_dir_all(db_path)?;
std::fs::write(version_path, env!("CARGO_PKG_VERSION"))?;
}

Expand Down
4 changes: 2 additions & 2 deletions sqld/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn maybe_migrate(db_path: &Path) -> anyhow::Result<()> {

fn detect_version(db_path: &Path) -> anyhow::Result<Version> {
let version_file_path = db_path.join(".version");
if !version_file_path.exists() {
if !version_file_path.try_exists()? {
return Ok(Version::Pre0_18);
}

Expand All @@ -41,7 +41,7 @@ fn migrate_step_from_pre_0_18(db_path: &Path) -> anyhow::Result<()> {
std::fs::create_dir_all(&ns_dir)?;

let maybe_link = |name| -> anyhow::Result<()> {
if db_path.join(name).exists() {
if db_path.join(name).try_exists()? {
std::fs::hard_link(db_path.join(name), ns_dir.join(name))?;
}

Expand Down

0 comments on commit dfb5b69

Please sign in to comment.