Skip to content

Commit 1e759cb

Browse files
committed
remove unnecessary mutex
1 parent dfd9e90 commit 1e759cb

7 files changed

Lines changed: 4 additions & 24 deletions

File tree

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ async fn main() -> anyhow::Result<()> {
1111
dotenvy::dotenv().ok();
1212
let config = crate::server::ServerConfig::parse();
1313

14-
use tokio::sync::Mutex;
1514
// Initialize logging system with colored output
1615
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
1716
use tracing_subscriber::util::SubscriberInitExt;
@@ -47,7 +46,7 @@ async fn main() -> anyhow::Result<()> {
4746
.await
4847
.context("failed to connect to postgres")?;
4948

50-
let state = Arc::new(Mutex::new(pointer::server::AppState { pool }));
49+
let state = Arc::new(pointer::server::AppState { pool });
5150
let file_state = state.clone();
5251
let render_state = state.clone();
5352

src/mcp/tools.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ pub async fn execute_file_content(
7676
payload: FileContentToolRequest,
7777
) -> Result<FileContentToolResponse, String> {
7878
let state = leptos::prelude::expect_context::<crate::server::GlobalAppState>();
79-
let pool = {
80-
let state = state.lock().await;
81-
state.pool.clone()
82-
};
79+
let pool = state.pool.clone();
8380
let db = PostgresDb::new(pool);
8481

8582
let commit = db
@@ -173,10 +170,7 @@ pub async fn execute_file_list(
173170
payload: FileListToolRequest,
174171
) -> Result<FileListToolResponse, String> {
175172
let state = leptos::prelude::expect_context::<crate::server::GlobalAppState>();
176-
let pool = {
177-
let state = state.lock().await;
178-
state.pool.clone()
179-
};
173+
let pool = state.pool.clone();
180174
let db = PostgresDb::new(pool.clone());
181175

182176
let commit = db

src/pages/file_viewer.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub async fn get_file_viewer_data(
104104
use std::path::Path;
105105

106106
let state = expect_context::<crate::server::GlobalAppState>();
107-
let state = state.lock().await;
108107
let db = PostgresDb::new(state.pool.clone());
109108

110109
let commit = db
@@ -216,7 +215,6 @@ pub async fn search_repo_paths(
216215
}
217216

218217
let state = expect_context::<crate::server::GlobalAppState>();
219-
let state = state.lock().await;
220218
let db = PostgresDb::new(state.pool.clone());
221219

222220
let commit = db
@@ -246,7 +244,6 @@ pub async fn fetch_symbol_insights(
246244
}
247245

248246
let state = expect_context::<crate::server::GlobalAppState>();
249-
let state = state.lock().await;
250247
let db = PostgresDb::new(state.pool.clone());
251248

252249
let commit = db

src/pages/repo_detail.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub async fn get_repo_branches(repo: String) -> Result<Vec<RepoBranchDisplay>, S
2626
use crate::db::{Database, postgres::PostgresDb};
2727

2828
let state = expect_context::<crate::server::GlobalAppState>();
29-
let state = state.lock().await;
3029
let db = PostgresDb::new(state.pool.clone());
3130

3231
let branches = db

src/server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::sync::Arc;
22

33
use clap::Parser;
44
use sqlx::postgres::PgPool;
5-
use tokio::sync::Mutex;
65

76
#[derive(Debug, Parser)]
87
pub struct ServerConfig {
@@ -22,4 +21,4 @@ pub struct AppState {
2221
pub pool: PgPool,
2322
}
2423

25-
pub type GlobalAppState = Arc<Mutex<AppState>>;
24+
pub type GlobalAppState = Arc<AppState>;

src/services/repo_service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::db::{Database, postgres::PostgresDb};
77
#[server]
88
pub async fn get_repositories(limit: usize) -> Result<Vec<RepoSummary>, ServerFnError> {
99
let state = expect_context::<crate::server::GlobalAppState>();
10-
let state = state.lock().await;
1110

1211
// Create a database instance using the pool
1312
let db = PostgresDb::new(state.pool.clone());

src/services/search_service.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub async fn search(query: String, page: u32) -> Result<SearchResultsPage, Serve
2121
TextSearchRequest::from_query_str_with_page(&query, normalized_page, DEFAULT_PAGE_SIZE)
2222
.map_err(|e| ServerFnError::new(e.to_string()))?;
2323
let state = expect_context::<crate::server::GlobalAppState>();
24-
let state = state.lock().await;
2524
let db = PostgresDb::new(state.pool.clone());
2625
db.text_search(&request)
2726
.await
@@ -34,7 +33,6 @@ pub async fn autocomplete_repositories(
3433
limit: i64,
3534
) -> Result<Vec<String>, ServerFnError> {
3635
let state = expect_context::<crate::server::GlobalAppState>();
37-
let state = state.lock().await;
3836
let db = PostgresDb::new(state.pool.clone());
3937
let normalized_limit = limit.max(1).min(20);
4038
db.autocomplete_repositories(term.trim(), normalized_limit)
@@ -49,7 +47,6 @@ pub async fn autocomplete_paths(
4947
limit: i64,
5048
) -> Result<Vec<String>, ServerFnError> {
5149
let state = expect_context::<crate::server::GlobalAppState>();
52-
let state = state.lock().await;
5350
let db = PostgresDb::new(state.pool.clone());
5451
let normalized_limit = limit.max(1).min(20);
5552
let repos: Vec<String> = repositories
@@ -72,7 +69,6 @@ pub async fn autocomplete_symbols(
7269
return Ok(Vec::new());
7370
}
7471
let state = expect_context::<crate::server::GlobalAppState>();
75-
let state = state.lock().await;
7672
let db = PostgresDb::new(state.pool.clone());
7773
let normalized_limit = limit.max(1).min(20);
7874
db.autocomplete_symbols(trimmed, normalized_limit)
@@ -87,7 +83,6 @@ pub async fn autocomplete_languages(
8783
limit: i64,
8884
) -> Result<Vec<String>, ServerFnError> {
8985
let state = expect_context::<crate::server::GlobalAppState>();
90-
let state = state.lock().await;
9186
let db = PostgresDb::new(state.pool.clone());
9287
let normalized_limit = limit.max(1).min(20);
9388
let repos: Vec<String> = repositories
@@ -107,7 +102,6 @@ pub async fn autocomplete_branches(
107102
limit: i64,
108103
) -> Result<Vec<String>, ServerFnError> {
109104
let state = expect_context::<crate::server::GlobalAppState>();
110-
let state = state.lock().await;
111105
let db = PostgresDb::new(state.pool.clone());
112106
let normalized_limit = limit.max(1).min(20);
113107
let repos: Vec<String> = repositories
@@ -127,7 +121,6 @@ pub async fn autocomplete_files(
127121
limit: i64,
128122
) -> Result<Vec<String>, ServerFnError> {
129123
let state = expect_context::<crate::server::GlobalAppState>();
130-
let state = state.lock().await;
131124
let db = PostgresDb::new(state.pool.clone());
132125
let normalized_limit = limit.max(1).min(20);
133126
let repos: Vec<String> = repositories

0 commit comments

Comments
 (0)