diff --git a/libips/src/repository/file_backend.rs b/libips/src/repository/file_backend.rs index 4cae015..4e12f96 100644 --- a/libips/src/repository/file_backend.rs +++ b/libips/src/repository/file_backend.rs @@ -1695,9 +1695,23 @@ impl FileBackend { } Err(RepositoryError::NotFound(format!("manifest for {} not found", fmri))) } - /// Fetch legacy catalog content (stub) - pub fn fetch_legacy_catalog(&self, _publisher: &str, _filename: &str) -> Result { - todo!("Implement legacy catalog format for REST API"); + /// Fetch catalog file path + pub fn get_catalog_file_path(&self, publisher: &str, filename: &str) -> Result { + if filename.contains('/') || filename.contains('\\') { + return Err(RepositoryError::PathPrefixError(filename.to_string())); + } + + let catalog_dir = Self::construct_catalog_path(&self.path, publisher); + let path = catalog_dir.join(filename); + + if path.exists() { + Ok(path) + } else { + Err(RepositoryError::NotFound(format!( + "Catalog file {} for publisher {} not found", + filename, publisher + ))) + } } /// Save the legacy pkg5.repository INI file for backward compatibility diff --git a/pkg6depotd/src/http/handlers/catalog.rs b/pkg6depotd/src/http/handlers/catalog.rs index e9dae32..3d9b6af 100644 --- a/pkg6depotd/src/http/handlers/catalog.rs +++ b/pkg6depotd/src/http/handlers/catalog.rs @@ -13,7 +13,7 @@ pub async fn get_catalog_v1( Path((publisher, filename)): Path<(String, String)>, req: Request, ) -> Result { - let path = repo.get_legacy_catalog(&publisher, &filename)?; + let path = repo.get_catalog_file_path(&publisher, &filename)?; let service = ServeFile::new(path); let result = service.oneshot(req).await; diff --git a/pkg6depotd/src/repo.rs b/pkg6depotd/src/repo.rs index 30ca92a..c3955d2 100644 --- a/pkg6depotd/src/repo.rs +++ b/pkg6depotd/src/repo.rs @@ -36,23 +36,11 @@ impl DepotRepo { backend.fetch_manifest_text(publisher, fmri).map_err(DepotError::Repo) } - pub fn get_legacy_catalog(&self, publisher: &str, filename: &str) -> Result { + pub fn get_catalog_file_path(&self, publisher: &str, filename: &str) -> Result { let backend = self.backend.lock().map_err(|e| DepotError::Server(format!("Lock poisoned: {}", e)))?; - backend.fetch_legacy_catalog(publisher, filename).map_err(DepotError::Repo) + backend.get_catalog_file_path(publisher, filename).map_err(DepotError::Repo) } - pub fn get_catalog_file_path(&self, publisher: &str, filename: &str) -> Option { - if filename.contains('/') || filename.contains('\\') { - return None; - } - let catalog_dir = self.get_catalog_path(publisher); - let path = catalog_dir.join(filename); - if path.exists() { - Some(path) - } else { - None - } - } pub fn get_info(&self) -> Result { let backend = self.backend.lock().map_err(|e| DepotError::Server(format!("Lock poisoned: {}", e)))?;