Skip to content

Commit

Permalink
fix backblaze pumper (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzlk authored Feb 14, 2025
1 parent 09d5fd0 commit 7f3930b
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions crates/bwmapserver/src/pumpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use tokio::io::AsyncReadExt;
use tracing::{error, info, warn};

pub async fn start_gsfs_pumper(client: reqwest::Client) -> Result<()> {
if let Err(e) = tokio::fs::create_dir_all("./pending/gsfs").await {
error!("failed to create pending/gsfs directory: {e}");
}
tokio::fs::create_dir_all("./pending/gsfs").await?;

let Ok(endpoint) = std::env::var("GSFSFE_ENDPOINT") else {
warn!("GSFSFE_ENDPOINT is not set, maps will NOT be uploaded to GSFS!!!");
Expand Down Expand Up @@ -68,9 +66,7 @@ pub async fn start_gsfs_pumper(client: reqwest::Client) -> Result<()> {
pub async fn start_backblaze_pumper(client: reqwest::Client) -> Result<()> {
info!("starting backblaze pumper");

if let Err(e) = tokio::fs::create_dir_all("./pending/backblaze").await {
error!("failed to create pending directory: {e}");
}
tokio::fs::create_dir_all("./pending/backblaze").await?;

match std::env::var("BACKBLAZE_DISABLED") {
Ok(v) if v == "true" => {
Expand Down Expand Up @@ -116,7 +112,7 @@ pub async fn start_backblaze_pumper(client: reqwest::Client) -> Result<()> {
loop {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;

let mut entries = match tokio::fs::read_dir("./pending").await {
let mut entries = match tokio::fs::read_dir("./pending/backblaze").await {
Ok(v) => v,
Err(e) => {
error!("could not readdir: {e:?}");
Expand All @@ -125,12 +121,6 @@ pub async fn start_backblaze_pumper(client: reqwest::Client) -> Result<()> {
};

while let Ok(Some(entry)) = entries.next_entry().await {
if let Ok(filetype) = entry.file_type().await {
if !filetype.is_file() {
continue;
}
}

let Ok(filename) = entry.file_name().into_string() else {
error!("could not stringify filename: {:?}", entry.file_name());
continue;
Expand Down

0 comments on commit 7f3930b

Please sign in to comment.