use std::sync::{Arc, Mutex};
use tokio::task::AbortHandle;

#[derive(Clone)]
pub struct ProjectBackupState {
    current: Arc<Mutex<Option<AbortHandle>>>,
}

impl ProjectBackupState {
    pub fn new() -> Self {
        Self {
            current: Arc::new(Mutex::new(None)),
        }
    }

    pub fn start(&self, abort: AbortHandle) {
        *self.current.lock().unwrap() = Some(abort);
    }

    pub fn finish(&self) {
        *self.current.lock().unwrap() = None;
    }
}
