Skip to content

Commit

Permalink
used lodestone_path for lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
C0W0 committed Jun 29, 2023
1 parent 3d1e11f commit eebdc58
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,6 @@ pub async fn run(
tracing_appender::non_blocking::WorkerGuard,
tokio::sync::oneshot::Sender<()>,
) {
let lockfile_path = "./lodestone.lock";
let file = if Path::new(lockfile_path).exists() {
std::fs::File::open(lockfile_path).expect("failed to open lockfile")
} else {
std::fs::File::create(lockfile_path).expect("failed to create lockfile")
};
if file.try_lock_exclusive().is_err() {
panic!("Another instance of lodestone might be running");
}

let _ = color_eyre::install().map_err(|e| {
error!("Failed to install color_eyre: {}", e);
});
Expand Down Expand Up @@ -394,6 +384,16 @@ pub async fn run(
check_for_core_update().await;
output_sys_info();

let lockfile_path = lodestone_path.join("lodestone.lock");
let file = if lockfile_path.as_path().exists() {
std::fs::File::open(lockfile_path.as_path()).expect("failed to open lockfile")
} else {
std::fs::File::create(lockfile_path.as_path()).expect("failed to create lockfile")
};
if file.try_lock_exclusive().is_err() {
panic!("Another instance of lodestone might be running");
}

let _ = migrate(&lodestone_path).map_err(|e| {
error!("Error while migrating lodestone: {}. Lodestone will still start, but one or more instance may be in an erroneous state", e);
});
Expand Down

0 comments on commit eebdc58

Please sign in to comment.