Conversation
`config_dir.join(&wavedash_config.upload_dir)` preserves both segments literally, so when the user's wavedash.toml has `upload_dir = "./..."` the resolved path rendered as `././...` in every error and log message. Add a small `clean_path` helper that collapses `CurDir` (`.`) and resolves `ParentDir` (`..`) where safe — no filesystem hit, no new dep. Applied at the single site where the upload_dir path is constructed, so everything downstream (error messages, `ServeDir` logging) benefits automatically. Verified: `upload_dir = "./nonexistent"` now prints `Error: Upload directory does not exist or is not a directory: nonexistent` instead of `././nonexistent`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @cloud9c's task in 1m 31s —— View job Code Review
The fix is correct and well-scoped for the A few things worth addressing:
let upload_dir = config_dir.join(&wavedash_config.upload_dir);The same
Edge case: absolute path + excess For an absolute This is unlikely in practice and the downstream No unit tests for Given the branchy logic (CurDir, ParentDir above root, empty-result guard), a small assert_eq!(clean_path(Path::new(".")), PathBuf::from("."));
assert_eq!(clean_path(Path::new("./build")), PathBuf::from("build"));
assert_eq!(clean_path(Path::new("././build")), PathBuf::from("build"));
assert_eq!(clean_path(Path::new("a/b/../c")), PathBuf::from("a/c"));
assert_eq!(clean_path(Path::new("../foo")), PathBuf::from("../foo"));
assert_eq!(clean_path(Path::new("/abs/./path")), PathBuf::from("/abs/path"));Minor:
Summary: The core fix is correct and the approach is idiomatic. The main gap is that |
Based on review of the original commit: - Simplify `clean_path` — drop the speculative `..`-resolution branch and narration comment. The helper is display-only; `..` handling was dead code for the paths we actually feed it (config_dir + wavedash.toml upload_dir). The remaining implementation is a one-line components filter. - Move to `src/util.rs` so `builds.rs` can reuse it — it had the exact same `config_dir.join(upload_dir)` pattern without any cleanup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @cloud9c's task in 1m 14s —— View job Code Review
This revision addresses all three gaps from the previous review. Here's the assessment: What's addressed
One minor style inconsistency
let upload_dir = crate::util::clean_path(&config_dir.join(&wavedash_config.upload_dir));while use crate::util::clean_path;
// ...
let upload_dir = clean_path(&config_dir.join(&wavedash_config.upload_dir));Should use the Tests are still missing
#[cfg(test)]
mod tests {
use super::*;
use std::path::Path;
#[test]
fn test_clean_path() {
assert_eq!(clean_path(Path::new(".")), PathBuf::from("."));
assert_eq!(clean_path(Path::new("./build")), PathBuf::from("build"));
assert_eq!(clean_path(Path::new("././build")), PathBuf::from("build"));
assert_eq!(clean_path(Path::new("a/b")), PathBuf::from("a/b"));
assert_eq!(clean_path(Path::new("../foo")), PathBuf::from("../foo")); // .. passed through
assert_eq!(clean_path(Path::new("/abs/./path")), PathBuf::from("/abs/path"));
}
}Summary: The core fix is solid and the |
Summary
config_dir.join(&wavedash_config.upload_dir)preserves both segments literally, so when a user's `wavedash.toml` has `upload_dir = "./..."` the resolved path rendered as `././...` in every error and log message. Noticed while QAing #28:```
Error: Multiple HTML files found in upload_dir (././build-rename-test):
```
Add a small `clean_path` helper that collapses `CurDir` (`.`) and resolves `ParentDir` (`..`) without touching the filesystem or pulling in a new dep. Applied at the single site where `upload_dir` is resolved, so everything downstream (error messages, `ServeDir` logs) benefits.
Before / after
`upload_dir = "./nonexistent"`:
Test plan
🤖 Generated with Claude Code