diff --git a/crates/tabby-common/src/config.rs b/crates/tabby-common/src/config.rs index e6a0a3093a7c..8e4e1daf1ced 100644 --- a/crates/tabby-common/src/config.rs +++ b/crates/tabby-common/src/config.rs @@ -9,7 +9,6 @@ use serde::{Deserialize, Serialize}; use crate::{ path::repositories_dir, terminal::{HeaderFormat, InfoMessage}, - SourceFile, }; #[derive(Serialize, Deserialize, Default)] @@ -150,9 +149,6 @@ impl Default for ServerConfig { #[async_trait] pub trait RepositoryAccess: Send + Sync { async fn list_repositories(&self) -> Result>; - fn start_snapshot(&self, _version: u64) {} - fn process_file(&self, _version: u64, _file: SourceFile) {} - fn finish_snapshot(&self, _version: u64) {} } pub struct ConfigRepositoryAccess; diff --git a/crates/tabby-scheduler/src/dataset.rs b/crates/tabby-scheduler/src/dataset.rs index 674fa3614b13..438749dfe5bd 100644 --- a/crates/tabby-scheduler/src/dataset.rs +++ b/crates/tabby-scheduler/src/dataset.rs @@ -15,7 +15,7 @@ use kdam::BarExt; use lazy_static::lazy_static; use serde_jsonlines::WriteExt; use tabby_common::{ - config::{RepositoryAccess, RepositoryConfig}, + config::RepositoryConfig, path::{dataset_dir, dependency_file}, DependencyFile, SourceFile, }; @@ -25,21 +25,11 @@ use tree_sitter_tags::TagsContext; use crate::utils::tqdm; trait RepositoryExt { - fn create_dataset( - &self, - writer: &mut impl Write, - access: &impl RepositoryAccess, - snapshot_version: u64, - ) -> Result<()>; + fn create_dataset(&self, writer: &mut impl Write) -> Result<()>; } impl RepositoryExt for RepositoryConfig { - fn create_dataset( - &self, - writer: &mut impl Write, - access: &impl RepositoryAccess, - snapshot_version: u64, - ) -> Result<()> { + fn create_dataset(&self, writer: &mut impl Write) -> Result<()> { let dir = self.dir(); let walk_dir_iter = || { @@ -81,7 +71,6 @@ impl RepositoryExt for RepositoryConfig { language, }; writer.write_json_lines([source_file.clone()])?; - access.process_file(snapshot_version, source_file); } Err(e) => { error!("Cannot read '{}': '{e}'", relative_path.display()); @@ -106,7 +95,7 @@ fn is_source_code(entry: &DirEntry) -> bool { } } -pub fn create_dataset(config: &[RepositoryConfig], access: &impl RepositoryAccess) -> Result<()> { +pub fn create_dataset(config: &[RepositoryConfig]) -> Result<()> { fs::remove_dir_all(dataset_dir()).ok(); fs::create_dir_all(dataset_dir())?; @@ -119,16 +108,10 @@ pub fn create_dataset(config: &[RepositoryConfig], access: &impl RepositoryAcces None, ); - let snapshot_version = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .expect("Failed to read system clock") - .as_millis() as u64; - access.start_snapshot(snapshot_version); - let mut deps = DependencyFile::default(); for repository in config { deps::collect(repository.dir().as_path(), &mut deps); - repository.create_dataset(&mut writer, access, snapshot_version)?; + repository.create_dataset(&mut writer)?; } serdeconv::to_json_file(&deps, dependency_file())?; diff --git a/crates/tabby-scheduler/src/lib.rs b/crates/tabby-scheduler/src/lib.rs index 7b14e9155f7e..e4b55d38a91f 100644 --- a/crates/tabby-scheduler/src/lib.rs +++ b/crates/tabby-scheduler/src/lib.rs @@ -15,7 +15,7 @@ use tracing::{error, info, warn}; pub async fn scheduler(now: bool, access: T) -> Result<()> { if now { let repositories = access.list_repositories().await?; - job_sync(&repositories, &access)?; + job_sync(&repositories)?; job_index(&repositories)?; } else { let access = Arc::new(access); @@ -37,7 +37,7 @@ pub async fn scheduler(now: bool, access: T) -> R .list_repositories() .await .expect("Must be able to retrieve repositories for sync"); - if let Err(e) = job_sync(&repositories, &*access) { + if let Err(e) = job_sync(&repositories) { error!("{e}"); } if let Err(e) = job_index(&repositories) { @@ -66,7 +66,7 @@ fn job_index(repositories: &[RepositoryConfig]) -> Result<()> { Ok(()) } -fn job_sync(repositories: &[RepositoryConfig], access: &impl RepositoryAccess) -> Result<()> { +fn job_sync(repositories: &[RepositoryConfig]) -> Result<()> { println!("Syncing {} repositories...", repositories.len()); let ret = repository::sync_repositories(repositories); if let Err(err) = ret { @@ -74,7 +74,7 @@ fn job_sync(repositories: &[RepositoryConfig], access: &impl RepositoryAccess) - } println!("Building dataset..."); - let ret = dataset::create_dataset(repositories, access); + let ret = dataset::create_dataset(repositories); if let Err(err) = ret { return Err(err.context("Failed to build dataset")); }