Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Apr 5, 2024
1 parent f6dce73 commit bcf69ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
3 changes: 0 additions & 3 deletions crates/tabby-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ impl Default for ServerConfig {
pub trait RepositoryAccess: Send + Sync {
async fn list_repositories(&self) -> Result<Vec<RepositoryConfig>>;

fn start_snapshot(&self) -> u64 {
Default::default()
}
fn process_file(&self, _version: u64, _file: SourceFile) {}
fn finish_snapshot(&self, _version: u64) {}
}
Expand Down
11 changes: 7 additions & 4 deletions crates/tabby-scheduler/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait RepositoryExt {
&self,
writer: &mut impl Write,
access: &impl RepositoryAccess,
cache_version: u64,
snapshot_version: u64,
) -> Result<()>;
}

Expand All @@ -38,7 +38,7 @@ impl RepositoryExt for RepositoryConfig {
&self,
writer: &mut impl Write,
access: &impl RepositoryAccess,
cache_version: u64,
snapshot_version: u64,
) -> Result<()> {

Check warning on line 42 in crates/tabby-scheduler/src/dataset.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-scheduler/src/dataset.rs#L37-L42

Added lines #L37 - L42 were not covered by tests
let dir = self.dir();

Expand Down Expand Up @@ -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);

Check warning on line 84 in crates/tabby-scheduler/src/dataset.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-scheduler/src/dataset.rs#L83-L84

Added lines #L83 - L84 were not covered by tests
}
Err(e) => {
error!("Cannot read {relative_path:?}: {e:?}");
Expand Down Expand Up @@ -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;

Check warning on line 125 in crates/tabby-scheduler/src/dataset.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-scheduler/src/dataset.rs#L122-L125

Added lines #L122 - L125 were not covered by tests
let mut deps = DependencyFile::default();
for repository in config {
deps::collect(repository.dir().as_path(), &mut deps);
Expand Down
17 changes: 0 additions & 17 deletions ee/tabby-webserver/src/hub/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bcf69ca

Please sign in to comment.