Remove some compiler warnings, most were dead_code warnings

This commit is contained in:
SeanOMik 2023-04-17 21:50:03 -04:00
parent 38c83f4ac7
commit 3c0259d49c
Signed by: SeanOMik
GPG Key ID: 568F326C7EB33ACB
7 changed files with 14 additions and 49 deletions

View File

@ -1,15 +0,0 @@
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"digest": "sha256:042a816809aac8d0f7d7cacac7965782ee2ecac3f21bcf9f24b1de1a7387b769"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 3370629,
"digest": "sha256:8921db27df2831fa6eaa85321205a2470c669b855f3ec95d5a3c2b46de0442c9"
}
]
}

View File

@ -1,5 +1,4 @@
use actix_web::{HttpResponse, get, HttpRequest, post, web, head, delete}; use actix_web::{HttpResponse, get, HttpRequest, web, head, delete};
use tracing::{debug, trace};
use crate::app_state::AppState; use crate::app_state::AppState;
@ -37,6 +36,6 @@ pub async fn pull_digest(path: web::Path<(String, String)>, state: web::Data<App
} }
#[delete("/{digest}")] #[delete("/{digest}")]
pub async fn delete_digest(req: HttpRequest, state: web::Data<AppState>) -> HttpResponse { pub async fn delete_digest(_req: HttpRequest, _state: web::Data<AppState>) -> HttpResponse {
todo!() todo!()
} }

View File

@ -1,15 +1,15 @@
use actix_web::{HttpResponse, HttpRequest, web, put, get, head}; use actix_web::{HttpResponse, web, put, get, head};
use tracing::log::warn; use tracing::log::warn;
use tracing::{debug, trace, info}; use tracing::{debug, info};
use crate::app_state::AppState; use crate::app_state::AppState;
use crate::database::Database; use crate::database::Database;
use crate::dto::digest::Digest; use crate::dto::digest::Digest;
use crate::dto::manifest::{Manifest, ImageManifest}; use crate::dto::manifest::Manifest;
#[put("/{reference}")] #[put("/{reference}")]
pub async fn upload_manifest(path: web::Path<(String, String)>, body: String, req: HttpRequest, state: web::Data<AppState>) -> HttpResponse { pub async fn upload_manifest(path: web::Path<(String, String)>, body: String, state: web::Data<AppState>) -> HttpResponse {
let (name, reference) = (path.0.to_owned(), path.1.to_owned()); let (name, reference) = (path.0.to_owned(), path.1.to_owned());
// Calculate the sha256 digest for the manifest. // Calculate the sha256 digest for the manifest.
@ -54,7 +54,7 @@ pub async fn upload_manifest(path: web::Path<(String, String)>, body: String, re
} }
#[get("/{reference}")] #[get("/{reference}")]
pub async fn pull_manifest(path: web::Path<(String, String)>, req: HttpRequest, state: web::Data<AppState>) -> HttpResponse { pub async fn pull_manifest(path: web::Path<(String, String)>, state: web::Data<AppState>) -> HttpResponse {
let (name, reference) = (path.0.to_owned(), path.1.to_owned()); let (name, reference) = (path.0.to_owned(), path.1.to_owned());
let database = &state.database; let database = &state.database;

View File

@ -27,7 +27,7 @@ pub async fn start_upload(path: web::Path<(String, )>) -> HttpResponse {
#[patch("/{uuid}")] #[patch("/{uuid}")]
pub async fn chunked_upload_layer(body: Bytes, path: web::Path<(String, String)>, req: HttpRequest, state: web::Data<AppState>) -> HttpResponse { pub async fn chunked_upload_layer(body: Bytes, path: web::Path<(String, String)>, req: HttpRequest, state: web::Data<AppState>) -> HttpResponse {
let full_uri = req.uri().to_string(); let full_uri = req.uri().to_string();
let (name, layer_uuid) = (path.0.to_owned(), path.1.to_owned()); let (_name, layer_uuid) = (path.0.to_owned(), path.1.to_owned());
debug!("Read body of size: {}", body.len()); debug!("Read body of size: {}", body.len());

View File

@ -2,8 +2,7 @@ use std::io::Read;
use async_trait::async_trait; use async_trait::async_trait;
use bytes::Bytes; use bytes::Bytes;
use sqlx::{sqlite::SqliteConnection, Sqlite, Pool}; use sqlx::{Sqlite, Pool};
use tokio::sync::Mutex;
use tracing::debug; use tracing::debug;
use chrono::{DateTime, Utc, NaiveDateTime}; use chrono::{DateTime, Utc, NaiveDateTime};
@ -67,7 +66,7 @@ impl Database for Pool<Sqlite> {
Ok(()) Ok(())
} }
async fn has_digest(&self, digest: &str) -> bool { async fn has_digest(&self, _digest: &str) -> bool {
todo!() todo!()
} }
@ -94,7 +93,7 @@ impl Database for Pool<Sqlite> {
Ok(Some(bytes)) Ok(Some(bytes))
} }
async fn digest_length(&self, digest: &str) -> usize { async fn digest_length(&self, _digest: &str) -> usize {
todo!() todo!()
} }
@ -144,7 +143,7 @@ impl Database for Pool<Sqlite> {
Ok(()) Ok(())
} }
async fn unlink_manifest_layer(&self, repository: &str, layer_digest: &str) { async fn unlink_manifest_layer(&self, _repository: &str, _layer_digest: &str) {
todo!() todo!()
} }

View File

@ -1,12 +1,10 @@
#[allow(dead_code)]
pub struct Digest { pub struct Digest {
algorithm: String, algorithm: String,
hex: String, hex: String,
} }
pub enum DigestError {
InvalidDigestString(String),
}
impl Digest { impl Digest {
/// Check if a string is a digest /// Check if a string is a digest
pub fn is_digest(s: &str) -> bool { pub fn is_digest(s: &str) -> bool {
@ -18,17 +16,4 @@ impl Digest {
false false
} }
pub fn from_string(s: &str) -> Result<Self, DigestError> {
if let Some(idx) = s.find(":") {
let (algo, hex) = s.split_at(idx);
return Ok(Self {
algorithm: algo.to_string(),
hex: hex.to_string(),
})
}
Err(DigestError::InvalidDigestString(String::from(s)))
}
} }

View File

@ -3,13 +3,10 @@ mod app_state;
mod database; mod database;
mod dto; mod dto;
use std::sync::Arc;
use actix_web::{web, App, HttpServer}; use actix_web::{web, App, HttpServer};
use actix_web::middleware::Logger; use actix_web::middleware::Logger;
use sqlx::sqlite::SqlitePoolOptions; use sqlx::sqlite::SqlitePoolOptions;
use tokio::sync::Mutex;
use tracing::{debug, Level}; use tracing::{debug, Level};
use app_state::AppState; use app_state::AppState;