Skip to content

Commit

Permalink
fix(webdav): correctly use application config
Browse files Browse the repository at this point in the history
The `inner_run` implementation used `self`
to read its config when it should use `RUSTIC_APP.config()`.

Some might say this is counterintuitive.
  • Loading branch information
nardoor committed Sep 17, 2024
1 parent abf1835 commit cba0359
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/commands/webdav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,39 +70,42 @@ impl WebDavCmd {
let config = RUSTIC_APP.config();
let repo = open_repository_indexed(&config.repository)?;

let path_template = self
let path_template = config
.webdav
.path_template
.clone()
.unwrap_or_else(|| "[{hostname}]/[{label}]/{time}".to_string());
let time_template = self
let time_template = config
.webdav
.time_template
.clone()
.unwrap_or_else(|| "%Y-%m-%d_%H-%M-%S".to_string());

let sn_filter = |sn: &_| config.snapshot_filter.matches(sn);

let vfs = if let Some(snap) = &self.snapshot_path {
let vfs = if let Some(snap) = &config.webdav.snapshot_path {
let node = repo.node_from_snapshot_path(snap, sn_filter)?;
Vfs::from_dir_node(&node)
} else {
let snapshots = repo.get_matching_snapshots(sn_filter)?;
let (latest, identical) = if self.symlinks {
let (latest, identical) = if config.webdav.symlinks {
(Latest::AsLink, IdenticalSnapshot::AsLink)
} else {
(Latest::AsDir, IdenticalSnapshot::AsDir)
};
Vfs::from_snapshots(snapshots, &path_template, &time_template, latest, identical)?
};

let addr = self
let addr = config
.webdav
.address
.clone()
.unwrap_or_else(|| "localhost:8000".to_string())
.to_socket_addrs()?
.next()
.ok_or_else(|| anyhow!("no address given"))?;

let file_access = self.file_access.as_ref().map_or_else(
let file_access = config.webdav.file_access.as_ref().map_or_else(
|| {
if repo.config().is_hot == Some(true) {
Ok(FilePolicy::Forbidden)
Expand Down

0 comments on commit cba0359

Please sign in to comment.