Refactor get_hostname
This commit is contained in:
parent
11d4b9d18c
commit
fc0aca09a5
@ -182,10 +182,7 @@ fn main() -> anyhow::Result<()> {
|
||||
source_name,
|
||||
destination_name,
|
||||
} => {
|
||||
let my_hostname = hostname::get()
|
||||
.expect("No hostname")
|
||||
.into_string()
|
||||
.expect("Hostname string must be sensible.");
|
||||
let my_hostname = get_hostname();
|
||||
let descriptor = load_descriptor(Path::new(".")).unwrap();
|
||||
let source = &descriptor.source[&source_name];
|
||||
let destination = &descriptor.piles[&destination_name];
|
||||
|
@ -32,6 +32,7 @@ use crate::labelling::{
|
||||
use crate::tree::{scan, FileTree, FileTree1};
|
||||
use log::info;
|
||||
|
||||
use crate::get_hostname;
|
||||
use crate::remote::backup_source_requester;
|
||||
use crate::remote::backup_source_requester::connect_to_remote;
|
||||
use anyhow::{anyhow, bail};
|
||||
@ -187,10 +188,7 @@ pub fn interactive_labelling_session(path: &Path, source_name: String) -> anyhow
|
||||
directory,
|
||||
} = source
|
||||
{
|
||||
let my_hostname = hostname::get()
|
||||
.expect("No hostname")
|
||||
.into_string()
|
||||
.expect("Hostname string must be sensible.");
|
||||
let my_hostname = get_hostname();
|
||||
let mut dir_scan = if &my_hostname == hostname {
|
||||
info!("Scanning source; this might take a little while...");
|
||||
scan(directory)?
|
||||
|
@ -3,3 +3,10 @@ pub mod descriptor;
|
||||
pub mod labelling;
|
||||
pub mod remote;
|
||||
pub mod tree;
|
||||
|
||||
pub fn get_hostname() -> String {
|
||||
hostname::get()
|
||||
.expect("No hostname")
|
||||
.into_string()
|
||||
.expect("Hostname string must be sensible.")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user