Update git output section
This commit is contained in:
@@ -12,7 +12,7 @@ use axum::{
|
||||
use clap::Parser;
|
||||
use std::sync::Arc;
|
||||
use tokio::process::Command;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -26,6 +26,7 @@ struct Args {
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
post_manager: Arc<RwLock<post_manager::PostManager>>,
|
||||
update_lock: Arc<Mutex<()>>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -38,6 +39,7 @@ async fn main() {
|
||||
|
||||
let app_state = AppState {
|
||||
post_manager: post_manager.clone(),
|
||||
update_lock: Arc::new(Mutex::new(())),
|
||||
};
|
||||
|
||||
if args.no_cache {
|
||||
@@ -105,6 +107,9 @@ async fn post_handler(
|
||||
}
|
||||
|
||||
async fn update_handler(State(state): State<AppState>) -> impl IntoResponse {
|
||||
// Acquire lock to prevent concurrent updates
|
||||
let _lock = state.update_lock.lock().await;
|
||||
|
||||
// Run git pull --autostash
|
||||
let output = Command::new("git")
|
||||
.arg("pull")
|
||||
|
||||
Reference in New Issue
Block a user