Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo to show disk space available #1020

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ clap_complete = "4"
clap_mangen = "0.2"
comrak = { version = "0.15", default-features = false }
fast_qr = { version = "0.8", features = ["svg"] }
fs_extra = "1.2.0"
futures = "0.3"
get_if_addrs = "0.5"
hex = "0.4"
Expand Down
7 changes: 7 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ Please set an explicit serve path like: `miniserve /my/path`")]
/// In case miniserve was invoked with --no-symlinks but the serve path is a symlink
#[error("The -P|--no-symlinks option was provided but the serve path '{0}' is a symlink")]
NoSymlinksOptionWithSymlinkServePath(String),

}

impl std::convert::From<fs_extra::error::Error> for ContextualError {
fn from(value: fs_extra::error::Error) -> Self {
todo!()
}
}

impl ResponseError for ContextualError {
fn status_code(&self) -> StatusCode {
match self {
Expand Down
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use fast_qr::QRBuilder;
use log::{error, warn};
use yansi::{Color, Paint};

use fs_extra::dir::get_size;

mod archive;
mod args;
mod auth;
Expand Down Expand Up @@ -222,6 +224,11 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {

println!("Serving path {}", Color::Yellow.paint(path_string).bold());

let folder_size = get_size(canon_path.as_path())?;
let kb_size = folder_size / 1024;
let mb_size = kb_size / 1024;
println!("Disk space available: {:?}MB", mb_size);

println!(
"Available at (non-exhaustive list):\n {}\n",
display_urls
Expand Down
3 changes: 3 additions & 0 deletions src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ pub fn page(
"/"
}
}
h3.title dir="ltr" {
bdi { ("Disk space available: XXX MB") }
}
div.toolbar {
@if conf.tar_enabled || conf.tar_gz_enabled || conf.zip_enabled {
div.download {
Expand Down