Skip to content

Commit

Permalink
fix: try fix deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Panakotta00 committed Jul 20, 2024
1 parent b747b57 commit 824d099
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ jobs:
script: |
cd ${{ secrets.DEPLOY_FOLDER }}
chmod 770 ./Website/FicsIt-Networks-Repository-Website
podman-compose up --build --force-recreate
podman-compose up -d --build --force-recreate
11 changes: 8 additions & 3 deletions Website/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::fs::File;
use std::path::Path;
use axum::body::Bytes;
use reqwest::StatusCode;
use tracing::error;
use url::Url;

pub enum URLOrFile {
Expand All @@ -10,11 +12,14 @@ pub enum URLOrFile {

pub async fn read_file_or_url(url: &str) -> Option<URLOrFile> {
Some(if let Ok(url) = Url::parse(url) {
let response = reqwest::get(url).await.unwrap();
let content = response.bytes().await.unwrap();
let response = reqwest::get(url).await.map_err(|e| error!("Failed to request '{url}': {e}")).ok()?;
if response.status() != StatusCode::OK {
return None
}
let content = response.bytes().await.map_err(|e| error!("Failed to read bytes from response of '{url}': {e}")).ok()?;
URLOrFile::URL(content)
} else {
let index = File::open(Path::new(url)).unwrap();
let index = File::open(Path::new(url)).map_err(|e| error!("Failed to open file '{url}': {e}")).ok()?;
URLOrFile::File(index)
})
}

0 comments on commit 824d099

Please sign in to comment.