✨ support more package compressions
This commit is contained in:
parent
788de4da7d
commit
656df96792
6 changed files with 115 additions and 36 deletions
|
@ -9,8 +9,8 @@ use pacco::pkg::package::PackageMetaInfo;
|
|||
use rocket::http::{ContentType, Status};
|
||||
use rocket::{State, get};
|
||||
|
||||
use pacco::pkg::Repository;
|
||||
use pacco::pkg::arch::Architecture;
|
||||
use pacco::pkg::{Package, Repository};
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
|
@ -103,14 +103,14 @@ pub async fn pkg_route(
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
if pkg_name.ends_with("pkg.tar.zst") {
|
||||
if Package::has_pkg_ext(&pkg_name) {
|
||||
pkg.increase_download_count().await;
|
||||
return DataResponse::new_file(
|
||||
&pkg.pkg_content_path().unwrap(),
|
||||
"application/tar".to_string(),
|
||||
cache_duration,
|
||||
);
|
||||
} else if pkg_name.ends_with("pkg.tar.zst.sig") {
|
||||
} else if pkg_name.ends_with("sig") {
|
||||
return DataResponse::new(
|
||||
pkg.sig_content().unwrap(),
|
||||
"application/pgp-signature".to_string(),
|
||||
|
@ -144,13 +144,13 @@ pub async fn pkg_route(
|
|||
|
||||
let pkg = repo.get_pkg(pkg_name).unwrap();
|
||||
|
||||
if pkg_name.ends_with("pkg.tar.zst") {
|
||||
if Package::has_pkg_ext(&pkg_name) {
|
||||
return DataResponse::new_file(
|
||||
&pkg.pkg_content_path().unwrap(),
|
||||
"application/tar".to_string(),
|
||||
cache_duration,
|
||||
);
|
||||
} else if pkg_name.ends_with("pkg.tar.zst.sig") {
|
||||
} else if pkg_name.ends_with("sig") {
|
||||
return DataResponse::new(
|
||||
pkg.sig_content().unwrap(),
|
||||
"application/pgp-signature".to_string(),
|
||||
|
|
|
@ -77,7 +77,10 @@ pub async fn upload_pkg(
|
|||
|
||||
let arch = Architecture::parse(&arch).ok_or_else(|| api_error("Invalid architecture"))?;
|
||||
|
||||
let pkg = Package::new(repo, arch, pkg_name, &version, rel);
|
||||
let (_, _, _, _, compression) = Package::extract_pkg_name(upload.pkg.name().unwrap())
|
||||
.ok_or_else(|| api_error("Package has weird filename"))?;
|
||||
|
||||
let pkg = Package::new(repo, arch, pkg_name, &version, rel, compression);
|
||||
|
||||
pkg.save(
|
||||
pkg_file,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue