From bcf69ca4a1ccd364211ef66cabf715254e7ea9b9 Mon Sep 17 00:00:00 2001 From: boxbeam Date: Fri, 5 Apr 2024 11:40:34 -0400 Subject: [PATCH] Apply suggestions --- crates/tabby-common/src/config.rs | 3 --- crates/tabby-scheduler/src/dataset.rs | 11 +++++++---- ee/tabby-webserver/src/hub/api.rs | 17 ----------------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/crates/tabby-common/src/config.rs b/crates/tabby-common/src/config.rs index c0581ee905a3..907a2bf1f472 100644 --- a/crates/tabby-common/src/config.rs +++ b/crates/tabby-common/src/config.rs @@ -147,9 +147,6 @@ impl Default for ServerConfig { pub trait RepositoryAccess: Send + Sync { async fn list_repositories(&self) -> Result>; - fn start_snapshot(&self) -> u64 { - Default::default() - } fn process_file(&self, _version: u64, _file: SourceFile) {} fn finish_snapshot(&self, _version: u64) {} } diff --git a/crates/tabby-scheduler/src/dataset.rs b/crates/tabby-scheduler/src/dataset.rs index d0e6d7d5d745..576ce8cf0a75 100644 --- a/crates/tabby-scheduler/src/dataset.rs +++ b/crates/tabby-scheduler/src/dataset.rs @@ -29,7 +29,7 @@ trait RepositoryExt { &self, writer: &mut impl Write, access: &impl RepositoryAccess, - cache_version: u64, + snapshot_version: u64, ) -> Result<()>; } @@ -38,7 +38,7 @@ impl RepositoryExt for RepositoryConfig { &self, writer: &mut impl Write, access: &impl RepositoryAccess, - cache_version: u64, + snapshot_version: u64, ) -> Result<()> { let dir = self.dir(); @@ -81,7 +81,7 @@ impl RepositoryExt for RepositoryConfig { content: file_content, }; writer.write_json_lines([source_file.clone()])?; - access.process_file(cache_version.clone(), source_file); + access.process_file(snapshot_version.clone(), source_file); } Err(e) => { error!("Cannot read {relative_path:?}: {e:?}"); @@ -119,7 +119,10 @@ pub fn create_dataset(config: &[RepositoryConfig], access: &impl RepositoryAcces None, ); - let snapshot_version = access.start_snapshot(); + let snapshot_version = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .expect("Failed to read system clock") + .as_millis() as u64; let mut deps = DependencyFile::default(); for repository in config { deps::collect(repository.dir().as_path(), &mut deps); diff --git a/ee/tabby-webserver/src/hub/api.rs b/ee/tabby-webserver/src/hub/api.rs index 98519a9cd9cd..15920a722994 100644 --- a/ee/tabby-webserver/src/hub/api.rs +++ b/ee/tabby-webserver/src/hub/api.rs @@ -199,23 +199,6 @@ impl RepositoryAccess for SchedulerClient { Ok(self.0.list_repositories(Context::current()).await?) } - fn start_snapshot(&self) -> u64 { - let cache = match RepositoryCache::new() { - Ok(cache) => cache, - Err(e) => { - error!("Failed to open repository cache: {e}"); - return 0; - } - }; - match cache.get_next_version() { - Ok(v) => v, - Err(e) => { - error!("Failed to get next repository cache version: {e}"); - 0 - } - } - } - fn process_file(&self, version: u64, file: SourceFile) { let cache = match RepositoryCache::new() { Ok(cache) => cache,