gitai/remote/models/
cached_repo.rs

1use serde::{Deserialize, Serialize};
2use std::sync::{Arc, Mutex};
3use std::time::SystemTime;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct CachedRepository {
7    /// The URL of the source repository
8    pub url: String,
9    /// The branch that was pulled
10    pub branch: String,
11    /// The path where the cached repository is stored
12    pub local_cache_path: String,
13    /// Timestamp of the last pull operation
14    pub last_pulled: SystemTime,
15    /// The commit hash of the cached repository
16    pub commit_hash: String,
17    // Using a simple boolean flag instead of a full mutex since we can't serialize mutex
18    // The actual locking mechanism will be handled separately in the cache manager
19    #[serde(skip)]
20    pub in_use: Arc<Mutex<bool>>,
21}
22
23impl CachedRepository {
24    pub fn new(url: String, branch: String, local_cache_path: String, commit_hash: String) -> Self {
25        Self {
26            url,
27            branch,
28            local_cache_path,
29            last_pulled: SystemTime::now(),
30            commit_hash,
31            in_use: Arc::new(Mutex::new(false)),
32        }
33    }
34}