Fix: local_source() gibt wieder ein Result zurueck
mount::target::local_source() gab bei fehlgeschlagener Adressaufloesung
(mac2ip findet die MAC-Adresse nicht) bisher den Platzhalter-String
"unresolved" zurueck und formatierte daraus eine syntaktisch gueltige,
aber sinnlose Mount-Quelle - statt den Fehler an den Aufrufer
durchzureichen. mount::cleanup_side_credentials() (WebDAV-Zweig)
erwartet bereits seit 690f727 ein Result von lokal_source(), um einen
Aufloesungsfehler zu loggen statt ihn zu verschlucken; ohne diese
Aenderung war das im Repository committete HEAD dadurch nicht
kompilierbar. local_source() gibt jetzt ein Result<String> zurueck und
reicht den Aufloesungsfehler ueber `?` durch.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+18
-7
@@ -54,7 +54,7 @@ pub fn build_target(
|
|||||||
|
|
||||||
let (source, mut options) = match side {
|
let (source, mut options) = match side {
|
||||||
Side::Local => (
|
Side::Local => (
|
||||||
local_source(&pair.local, settings),
|
local_source(&pair.local, settings)?,
|
||||||
parse_options(&pair.local.extra_options),
|
parse_options(&pair.local.extra_options),
|
||||||
),
|
),
|
||||||
Side::Cloud => (
|
Side::Cloud => (
|
||||||
@@ -169,11 +169,14 @@ fn run_id(username: &str, flag: &str) -> Result<u32> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_source(local: &LocalSide, settings: &GlobalSettings) -> String {
|
/// Löst die konfigurierte lokale Adresse auf und formatiert die Mount-Quelle daraus. Gibt
|
||||||
let ip = address::resolve_ip(&local.address, settings)
|
/// einen Fehler zurück, statt eine fehlgeschlagene Auflösung (z. B. `mac2ip` findet die
|
||||||
.map(|ip| ip.to_string())
|
/// MAC-Adresse nicht) hinter dem Platzhalter-String `"unresolved"` zu verstecken - Aufrufer
|
||||||
.unwrap_or_else(|_| "unresolved".to_string());
|
/// sollen einen echten Auflösungsfehler von einer tatsächlich formatierten, aber unerreichbaren
|
||||||
format_source(local.kind, &ip, &local.share)
|
/// Quelle unterscheiden können.
|
||||||
|
pub fn local_source(local: &LocalSide, settings: &GlobalSettings) -> Result<String> {
|
||||||
|
let ip = address::resolve_ip(&local.address, settings)?;
|
||||||
|
Ok(format_source(local.kind, &ip.to_string(), &local.share))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cloud_source(cloud: &CloudSide) -> String {
|
pub fn cloud_source(cloud: &CloudSide) -> String {
|
||||||
@@ -297,11 +300,19 @@ mod tests {
|
|||||||
fn local_source_formats_smb_unc_path() {
|
fn local_source_formats_smb_unc_path() {
|
||||||
let pair = sample_pair();
|
let pair = sample_pair();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
local_source(&pair.local, &GlobalSettings::default()),
|
local_source(&pair.local, &GlobalSettings::default()).expect("local_source"),
|
||||||
"//192.168.1.10/share"
|
"//192.168.1.10/share"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn local_source_propagates_mac2ip_error() {
|
||||||
|
let mut pair = sample_pair();
|
||||||
|
pair.local.address = crate::config::LocalAddress::Mac("00:11:22:33:44:55".into());
|
||||||
|
let err = local_source(&pair.local, &GlobalSettings::default()).unwrap_err();
|
||||||
|
assert!(matches!(err, crate::error::Error::Mac2Ip { .. }));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cloud_source_uses_full_url_for_webdav() {
|
fn cloud_source_uses_full_url_for_webdav() {
|
||||||
let pair = sample_pair();
|
let pair = sample_pair();
|
||||||
|
|||||||
@@ -215,7 +215,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn local_source_formats_smb_unc_path() {
|
fn local_source_formats_smb_unc_path() {
|
||||||
let pair = sample_pair(MountKind::Smb, MountKind::WebDav);
|
let pair = sample_pair(MountKind::Smb, MountKind::WebDav);
|
||||||
let source = target::local_source(&pair.local, &GlobalSettings::default());
|
let source =
|
||||||
|
target::local_source(&pair.local, &GlobalSettings::default()).expect("local_source");
|
||||||
assert_eq!(source, "//192.168.1.10/share");
|
assert_eq!(source, "//192.168.1.10/share");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user