smart mirroring
This commit is contained in:
parent
68cb32f07b
commit
7647616242
13 changed files with 701 additions and 67 deletions
|
@ -1,6 +1,6 @@
|
|||
use based::request::api::{FallibleApiResponse, api_error};
|
||||
use rocket::tokio::io::AsyncReadExt;
|
||||
use rocket::{FromForm, post};
|
||||
use rocket::{FromForm, State, post};
|
||||
use serde_json::json;
|
||||
|
||||
use pacco::pkg::Package;
|
||||
|
@ -12,6 +12,8 @@ use pacco::pkg::arch::Architecture;
|
|||
use rocket::form::Form;
|
||||
use rocket::fs::TempFile;
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
#[derive(FromForm)]
|
||||
pub struct PkgUpload<'r> {
|
||||
name: String,
|
||||
|
@ -37,12 +39,17 @@ pub async fn upload_pkg(
|
|||
repo: &str,
|
||||
upload: Form<PkgUpload<'_>>,
|
||||
user: based::auth::APIUser,
|
||||
config: &State<Config>,
|
||||
) -> FallibleApiResponse {
|
||||
// TODO : Permission System
|
||||
if !user.0.is_admin() {
|
||||
return Err(api_error("Forbidden"));
|
||||
}
|
||||
|
||||
if config.is_mirrored_repo(repo) {
|
||||
return Err(api_error("This repository is a mirror."));
|
||||
}
|
||||
|
||||
let pkg = Package::new(
|
||||
repo,
|
||||
Architecture::parse(&upload.arch).ok_or_else(|| api_error("Invalid architecture"))?,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue