Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub async fn handle_build_push(config_path: PathBuf, verbose: bool, message: Opt
let config_dir = config_path
.parent()
.ok_or_else(|| anyhow::anyhow!("Config file has no parent directory"))?;
let upload_dir = config_dir.join(&wavedash_config.upload_dir);
let upload_dir = crate::util::clean_path(&config_dir.join(&wavedash_config.upload_dir));

// Verify source directory exists
if !upload_dir.exists() {
Expand Down
3 changes: 2 additions & 1 deletion src/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use url::Url;
use crate::auth::AuthManager;
use crate::config::{self, EngineKind, WavedashConfig};
use crate::file_staging::FileStaging;
use crate::util::clean_path;

mod cert;
mod entrypoint;
Expand Down Expand Up @@ -106,7 +107,7 @@ pub async fn handle_dev(config_path: Option<PathBuf>, verbose: bool, no_open: bo

let wavedash_config = WavedashConfig::load(&config_path)?;
let config_dir = config_parent_dir(&config_path)?;
let upload_dir = config_dir.join(&wavedash_config.upload_dir);
let upload_dir = clean_path(&config_dir.join(&wavedash_config.upload_dir));

if !upload_dir.exists() || !upload_dir.is_dir() {
anyhow::bail!(
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod dev;
mod file_staging;
mod init;
mod updater;
mod util;

use anyhow::Result;
use auth::{login_with_browser, AuthManager, AuthSource};
Expand Down
19 changes: 19 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::path::{Component, Path, PathBuf};

/// Collapse `.` segments so paths rendered in logs and errors don't end up
/// with leading `./` noise when `wavedash.toml`'s `upload_dir` already starts
/// with `./`. Display-only — does not touch the filesystem and does not
/// resolve `..` (paths we consume come from `config_dir.join(upload_dir)`, so
/// the `..` case is vanishingly rare and correctly passed through to the
/// filesystem calls that follow).
pub fn clean_path(p: &Path) -> PathBuf {
let cleaned: PathBuf = p
.components()
.filter(|c| !matches!(c, Component::CurDir))
.collect();
if cleaned.as_os_str().is_empty() {
PathBuf::from(".")
} else {
cleaned
}
}
Loading