Skip to content

Commit

Permalink
repo: ensure ciel lock file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed May 10, 2024
1 parent 77ba90b commit 901b870
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/repo/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use std::{
thread::sleep,
time::Duration,
};
use crate::info;
use console::style;

use super::refresh_repo;

Expand Down Expand Up @@ -67,11 +69,18 @@ fn refresh_once(pool_path: &Path) -> Result<()> {
}

pub fn start_monitor(pool_path: &Path, stop_token: Receiver<()>) -> Result<()> {
// ensure lock exists
let lock_path = pool_path.join(LOCK_FILE);
if !Path::exists(&lock_path) {
File::create(&lock_path)?;
info!("Creating lock file at {}...", LOCK_FILE);
}

let mut inotify = Inotify::init()?;
let mut buffer = [0u8; 1024];
let mut ignore_next = false;
inotify.watches().add(
pool_path.join(LOCK_FILE),
&lock_path,
WatchMask::DELETE_SELF | WatchMask::CLOSE_WRITE | WatchMask::CREATE,
)?;

Expand Down

0 comments on commit 901b870

Please sign in to comment.