fix(server): also properly serve file database
parent
b8d53f43b6
commit
b85f57b112
|
@ -20,6 +20,8 @@ use tower_http::services::{ServeDir, ServeFile};
|
||||||
use tower_http::validate_request::ValidateRequestHeaderLayer;
|
use tower_http::validate_request::ValidateRequestHeaderLayer;
|
||||||
use uuid::Uuid;
|
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> {
|
pub fn router(api_key: &str) -> Router<crate::Global> {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route(
|
.route(
|
||||||
|
@ -120,9 +122,9 @@ async fn get_file(
|
||||||
let repo_dir = global.config.repo_dir.join(&repo).join(&arch);
|
let repo_dir = global.config.repo_dir.join(&repo).join(&arch);
|
||||||
let repo_exists = tokio::fs::try_exists(&repo_dir).await?;
|
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
|
// 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");
|
file_name.push_str(".tar.gz");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue