feat: log added packages

concurrent-repos
Jef Roosens 2024-05-29 10:02:38 +02:00
parent 60d4478d83
commit fc844c685f
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 12 additions and 10 deletions

View File

@ -133,7 +133,7 @@ pub async fn insert(conn: &DbConn, repo_id: i32, pkg: crate::repo::package::Pack
.chain( .chain(
info.makedepends info.makedepends
.iter() .iter()
.map(|s| (PackageRelatedEnum::Depend, s)), .map(|s| (PackageRelatedEnum::Makedepend, s)),
) )
.chain( .chain(
info.checkdepends info.checkdepends

View File

@ -219,7 +219,7 @@ impl MetaRepoMgr {
conn: &DbConn, conn: &DbConn,
reader: &mut R, reader: &mut R,
repo: &str, repo: &str,
) -> crate::Result<()> { ) -> crate::Result<(String, String, String)> {
// Copy file contents to temporary path so libarchive can work with it // Copy file contents to temporary path so libarchive can work with it
let uuid: uuid::fmt::Simple = Uuid::new_v4().into(); let uuid: uuid::fmt::Simple = Uuid::new_v4().into();
let path = self.repo_dir.join(uuid.to_string()); let path = self.repo_dir.join(uuid.to_string());
@ -262,6 +262,8 @@ impl MetaRepoMgr {
let dest_pkg_path = self.repo_dir.join(repo).join(pkg.file_name()); let dest_pkg_path = self.repo_dir.join(repo).join(pkg.file_name());
// Insert new package into database // Insert new package into database
let name = pkg.info.name.clone();
let version = pkg.info.version.clone();
let arch = pkg.info.arch.clone(); let arch = pkg.info.arch.clone();
db::query::package::insert(conn, repo_id, pkg).await?; db::query::package::insert(conn, repo_id, pkg).await?;
@ -271,9 +273,11 @@ impl MetaRepoMgr {
// Synchronize archive databases // Synchronize archive databases
if arch == ANY_ARCH { if arch == ANY_ARCH {
self.generate_archives_all(conn, repo).await self.generate_archives_all(conn, repo).await?;
} else { } else {
self.generate_archives(conn, repo, &arch).await self.generate_archives(conn, repo, &arch).await?;
} }
Ok((name, version, arch))
} }
} }

View File

@ -69,19 +69,17 @@ async fn post_package_archive(
Path(repo): Path<String>, Path(repo): Path<String>,
body: Body, body: Body,
) -> crate::Result<()> { ) -> crate::Result<()> {
let body = body.into_data_stream(); let mut body = StreamReader::new(body.into_data_stream().map_err(std::io::Error::other));
let body = body.map_err(std::io::Error::other); let (name, version, arch) = global
let mut body = StreamReader::new(body);
global
.repo_manager .repo_manager
.write() .write()
.await .await
.add_pkg_from_reader(&global.db, &mut body, &repo) .add_pkg_from_reader(&global.db, &mut body, &repo)
.await?; .await?;
Ok(()) tracing::info!("Added '{}-{}' to repository '{}' ({})", name, version, repo, arch);
//tracing::info!("Added '{}' to repository '{}'", pkg.file_name(), repo); Ok(())
} }
async fn delete_repo( async fn delete_repo(