perf: Remove blocking std::fs IO from nvim socket locator
This commit is contained in:
1 parent
c9ba5e79dd
commit
f8c0d58415
1 file changed
+7
-7
@@ -99,7 +99,7 @@ async fn get_socket_path() -> Result<String, String> {
|
|||||||
std::env::var("USERPROFILE").unwrap_or_else(|_| "C:\\Users\\reazul.ashraf".into());
|
std::env::var("USERPROFILE").unwrap_or_else(|_| "C:\\Users\\reazul.ashraf".into());
|
||||||
let path = format!("{}\\.gemini\\active_nvim.txt", profile);
|
let path = format!("{}\\.gemini\\active_nvim.txt", profile);
|
||||||
|
|
||||||
if let Ok(content) = std::fs::read_to_string(&path) {
|
if let Ok(content) = tokio::fs::read_to_string(&path).await {
|
||||||
let p = content.trim().to_string();
|
let p = content.trim().to_string();
|
||||||
if !p.is_empty() {
|
if !p.is_empty() {
|
||||||
if p.starts_with(r"\\.\pipe\") {
|
if p.starts_with(r"\\.\pipe\") {
|
||||||
@@ -113,8 +113,8 @@ async fn get_socket_path() -> Result<String, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracing::warn!("active_nvim.txt missing or invalid, falling back to pipe discovery");
|
tracing::warn!("active_nvim.txt missing or invalid, falling back to pipe discovery");
|
||||||
if let Ok(dir) = std::fs::read_dir(r"\\.\pipe\") {
|
if let Ok(mut dir) = tokio::fs::read_dir(r"\\.\pipe\").await {
|
||||||
for entry in dir.flatten() {
|
while let Ok(Some(entry)) = dir.next_entry().await {
|
||||||
let name = entry.file_name();
|
let name = entry.file_name();
|
||||||
let name_str = name.to_string_lossy();
|
let name_str = name.to_string_lossy();
|
||||||
if name_str.starts_with("nvim.") {
|
if name_str.starts_with("nvim.") {
|
||||||
@@ -129,7 +129,7 @@ async fn get_socket_path() -> Result<String, String> {
|
|||||||
async fn get_socket_path() -> Result<String, String> {
|
async fn get_socket_path() -> Result<String, String> {
|
||||||
if let Ok(home) = std::env::var("HOME") {
|
if let Ok(home) = std::env::var("HOME") {
|
||||||
let path = format!("{}/.gemini/active_nvim.txt", home);
|
let path = format!("{}/.gemini/active_nvim.txt", home);
|
||||||
if let Ok(content) = std::fs::read_to_string(&path) {
|
if let Ok(content) = tokio::fs::read_to_string(&path).await {
|
||||||
let p = content.trim().to_string();
|
let p = content.trim().to_string();
|
||||||
if !p.is_empty() {
|
if !p.is_empty() {
|
||||||
return Ok(p);
|
return Ok(p);
|
||||||
@@ -137,12 +137,12 @@ async fn get_socket_path() -> Result<String, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(entries) = std::fs::read_dir("/tmp") {
|
if let Ok(mut entries) = tokio::fs::read_dir("/tmp").await {
|
||||||
for entry in entries.flatten() {
|
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||||
if let Ok(name) = entry.file_name().into_string() {
|
if let Ok(name) = entry.file_name().into_string() {
|
||||||
if name.starts_with("nvim.") {
|
if name.starts_with("nvim.") {
|
||||||
let path = entry.path().join("0");
|
let path = entry.path().join("0");
|
||||||
if path.exists() {
|
if tokio::fs::try_exists(&path).await.unwrap_or(false) {
|
||||||
return Ok(path.to_string_lossy().to_string());
|
return Ok(path.to_string_lossy().to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user