diff --git a/ee/tabby-webserver/src/repositories/mod.rs b/ee/tabby-webserver/src/repositories/mod.rs index c3aaa7ae6e2d..d4b43df4aa3c 100644 --- a/ee/tabby-webserver/src/repositories/mod.rs +++ b/ee/tabby-webserver/src/repositories/mod.rs @@ -43,7 +43,7 @@ async fn resolve_path( Path(repo): Path, ) -> Result { let relpath = repo.os_path(); - let Some(root) = rs.find_repository(&repo.kind, &repo.id).await else { + let Some(root) = rs.find_repository(&repo).await else { return Err(StatusCode::NOT_FOUND); }; let full_path = root.join(relpath); diff --git a/ee/tabby-webserver/src/repositories/resolve.rs b/ee/tabby-webserver/src/repositories/resolve.rs index 939388402acd..e95b9c814d04 100644 --- a/ee/tabby-webserver/src/repositories/resolve.rs +++ b/ee/tabby-webserver/src/repositories/resolve.rs @@ -125,8 +125,12 @@ impl ResolveState { Ok(resp.map(boxed)) } - pub async fn find_repository(&self, kind: &RepositoryKind, id: &ID) -> Option { - let repository = self.service.get(kind, id).await.ok()?; + pub async fn find_repository(&self, params: &ResolveParams) -> Option { + let repository = self + .service + .resolve_repository(¶ms.kind, ¶ms.id) + .await + .ok()?; Some(repository.dir) } } diff --git a/ee/tabby-webserver/src/schema/repository.rs b/ee/tabby-webserver/src/schema/repository.rs index 30debc184581..0a466c932341 100644 --- a/ee/tabby-webserver/src/schema/repository.rs +++ b/ee/tabby-webserver/src/schema/repository.rs @@ -92,7 +92,7 @@ pub trait RepositoryProvider { #[async_trait] pub trait RepositoryService: Send + Sync + RepositoryAccess { async fn repository_list(&self) -> Result>; - async fn get(&self, kind: &RepositoryKind, id: &ID) -> Result; + async fn resolve_repository(&self, kind: &RepositoryKind, id: &ID) -> Result; async fn search_files( &self, kind: &RepositoryKind, diff --git a/ee/tabby-webserver/src/service/repository.rs b/ee/tabby-webserver/src/service/repository.rs index 43f80438f635..e8b643240626 100644 --- a/ee/tabby-webserver/src/service/repository.rs +++ b/ee/tabby-webserver/src/service/repository.rs @@ -87,7 +87,7 @@ impl RepositoryService for RepositoryServiceImpl { Ok(all) } - async fn get(&self, kind: &RepositoryKind, id: &ID) -> Result { + async fn resolve_repository(&self, kind: &RepositoryKind, id: &ID) -> Result { match kind { RepositoryKind::Git => self.git().get_repository(id).await, RepositoryKind::Github => self.github().get_repository(id).await, @@ -105,7 +105,7 @@ impl RepositoryService for RepositoryServiceImpl { if pattern.trim().is_empty() { return Ok(vec![]); } - let dir = self.get(kind, id).await?.dir; + let dir = self.resolve_repository(kind, id).await?.dir; let pattern = pattern.to_owned(); let matching = tokio::task::spawn_blocking(move || async move {