From 56e1ab4a06bc6426c48678130d1e9e78cc405131 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 19 Feb 2026 03:48:17 -0600 Subject: [PATCH] Remove unused methods from ServeSession and clean up syncback logic - Deleted the `project_port` and `serve_address` methods from the `ServeSession` implementation as they were no longer needed. - Removed the `scan_directory` and `normalize_existing_path` helper functions from the `syncback_loop_with_stats` function, streamlining the code and improving maintainability. These changes aim to enhance code clarity and reduce unnecessary complexity in the session and syncback functionalities. --- src/serve_session.rs | 9 ----- src/syncback/mod.rs | 93 -------------------------------------------- 2 files changed, 102 deletions(-) diff --git a/src/serve_session.rs b/src/serve_session.rs index e8cdfbc3..fd16b299 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -1,7 +1,6 @@ use std::{ collections::HashSet, io, - net::IpAddr, path::{Path, PathBuf}, sync::{Arc, Mutex, MutexGuard}, time::Instant, @@ -456,10 +455,6 @@ impl ServeSession { .expect("all top-level projects must have their name set") } - pub fn project_port(&self) -> Option { - self.root_project.serve_port - } - pub fn place_id(&self) -> Option { self.root_project.place_id } @@ -480,10 +475,6 @@ impl ServeSession { self.root_project.blocked_place_ids.as_ref() } - pub fn serve_address(&self) -> Option { - self.root_project.serve_address - } - pub fn root_dir(&self) -> &Path { self.root_project.folder_location() } diff --git a/src/syncback/mod.rs b/src/syncback/mod.rs index b2d743e8..ebcf0063 100644 --- a/src/syncback/mod.rs +++ b/src/syncback/mod.rs @@ -381,50 +381,6 @@ pub fn syncback_loop_with_stats( } } - // Recursively scan each source directory - fn scan_directory( - dir: &Path, - paths: &mut HashSet, - ignore_patterns: &Option>, - project_path: &Path, - ) { - log::trace!("Scanning directory: {}", dir.display()); - let entries = match std::fs::read_dir(dir) { - Ok(e) => e, - Err(e) => { - log::trace!("Failed to read directory {}: {}", dir.display(), e); - return; - } - }; - - for entry in entries.flatten() { - let path = entry.path(); - - // Skip paths matching ignore patterns - if !is_valid_path(ignore_patterns, project_path, &path) { - log::trace!("Skipping {} (matches ignore pattern)", path.display()); - continue; - } - - // Skip hidden files/directories (starting with .), except - // .gitkeep which is managed by Rojo and must be tracked for - // cleanup when directories are no longer empty. - if let Some(name) = path.file_name().and_then(|n| n.to_str()) { - if name.starts_with('.') && name != ".gitkeep" { - log::trace!("Skipping {} (hidden)", path.display()); - continue; - } - } - - log::trace!("Found path: {}", path.display()); - paths.insert(path.clone()); - - if path.is_dir() { - scan_directory(&path, paths, ignore_patterns, project_path); - } - } - } - log::trace!( "dirs_to_scan: {:?}", dirs_to_scan @@ -699,59 +655,10 @@ pub fn syncback_loop_with_stats( } } - // Helper to normalize a path by: - // 1. Canonicalizing to resolve symlinks (important on macOS where /var -> /private/var) - // 2. Stripping UNC prefix on Windows - fn normalize_existing_path(p: &Path) -> PathBuf { - // First try to canonicalize to resolve symlinks - // This is important on macOS where /var is a symlink to /private/var - let canonicalized = std::fs::canonicalize(p).unwrap_or_else(|_| p.to_path_buf()); - strip_unc_prefix(canonicalized) - } - let canonical_project_path = strip_unc_prefix( std::fs::canonicalize(project_path).unwrap_or_else(|_| project_path.to_path_buf()), ); - // Helper to canonicalize a path that may not exist yet. - // Tries to canonicalize the full path, then falls back to canonicalizing - // the nearest existing ancestor and appending the remaining components. - fn canonicalize_maybe_nonexistent(p: &Path) -> PathBuf { - // Try full canonicalization first (works if path exists) - if let Ok(canonical) = std::fs::canonicalize(p) { - return strip_unc_prefix(canonical); - } - - // Path doesn't exist - find the nearest existing ancestor and canonicalize that, - // then append the remaining path components. - let mut existing_ancestor = p.to_path_buf(); - let mut suffix_components = Vec::new(); - - while !existing_ancestor.as_os_str().is_empty() { - if existing_ancestor.exists() { - break; - } - if let Some(file_name) = existing_ancestor.file_name() { - suffix_components.push(file_name.to_owned()); - } - if !existing_ancestor.pop() { - break; - } - } - - // Canonicalize the existing ancestor - let canonical_ancestor = std::fs::canonicalize(&existing_ancestor) - .map(strip_unc_prefix) - .unwrap_or(existing_ancestor); - - // Append the suffix components in reverse order - let mut result = canonical_ancestor; - for component in suffix_components.into_iter().rev() { - result.push(component); - } - result - } - let added_paths: HashSet = fs_snapshot .added_paths() .into_iter()