fix(server): also properly serve file database

repo-db
Jef Roosens 2023-08-03 15:08:34 +02:00
parent b8d53f43b6
commit b85f57b112
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 4 additions and 2 deletions

View File

@ -20,6 +20,8 @@ use tower_http::services::{ServeDir, ServeFile};
use tower_http::validate_request::ValidateRequestHeaderLayer;
use uuid::Uuid;
const DB_FILE_EXTS: [&str; 4] = [".db", ".files", ".db.tar.gz", ".files.tar.gz"];
pub fn router(api_key: &str) -> Router<crate::Global> {
Router::new()
.route(
@ -120,9 +122,9 @@ async fn get_file(
let repo_dir = global.config.repo_dir.join(&repo).join(&arch);
let repo_exists = tokio::fs::try_exists(&repo_dir).await?;
let res = if file_name.ends_with(".db") || file_name.ends_with(".db.tar.gz") {
let res = if DB_FILE_EXTS.iter().any(|ext| file_name.ends_with(ext)) {
// Append tar extension to ensure we find the file
if file_name.ends_with(".db") {
if !file_name.ends_with(".tar.gz") {
file_name.push_str(".tar.gz");
};