Skip to content

Commit

Permalink
fix: precondition checker fails if paths do not exist (but can be cre…
Browse files Browse the repository at this point in the history
…ated)
  • Loading branch information
amokfa committed Nov 20, 2024
1 parent 9a62522 commit 6a2d2b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion uplink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uplink"
version = "2.16.1"
version = "2.16.2"
authors = ["tekjar <raviteja@bytebeam.io>"]
edition = "2021"

Expand Down
10 changes: 9 additions & 1 deletion uplink/src/collector/preconditions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{fs::metadata, os::unix::fs::MetadataExt, sync::Arc};

use anyhow::Context;
use flume::Receiver;
use human_bytes::human_bytes;
use log::debug;
Expand All @@ -13,6 +13,8 @@ pub enum Error {
Io(#[from] std::io::Error),
#[error("Disk space is insufficient: {0}")]
InsufficientDisk(String),
#[error("Error while checking disk space: {0}")]
PreconditionError(#[from] anyhow::Error),
}

#[derive(Deserialize, Clone, PartialEq, Eq, Debug)]
Expand Down Expand Up @@ -65,6 +67,12 @@ impl PreconditionChecker {
let Some(mut required_free_space) = preconditions.uncompressed_length else {
return Ok(());
};

std::fs::create_dir_all(self.config.downloader.path.as_path())
.context("Couldn't create download directory")?;
std::fs::create_dir_all(self.config.precondition_checks.as_ref().unwrap().path.as_path())
.context("Couldn't create precondition directory")?;

let disk_free_space =
fs2::free_space(&self.config.precondition_checks.as_ref().unwrap().path)? as usize;

Expand Down

0 comments on commit 6a2d2b7

Please sign in to comment.