File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1732,9 +1732,7 @@ pub fn run_with_progress(
17321732 let time_end = Utc :: now ( ) ;
17331733
17341734 // Build snapshot metadata
1735- let hostname = nix:: unistd:: gethostname ( )
1736- . map ( |h| h. to_string_lossy ( ) . to_string ( ) )
1737- . unwrap_or_else ( |_| "unknown" . into ( ) ) ;
1735+ let hostname = crate :: platform:: hostname ( ) ;
17381736 let username = std:: env:: var ( "USER" ) . unwrap_or_else ( |_| "unknown" . into ( ) ) ;
17391737
17401738 let snapshot_meta = SnapshotMeta {
Original file line number Diff line number Diff line change 11pub mod fs;
22pub mod shell;
3+
4+ /// Return the system hostname, or `"unknown"` if it cannot be determined.
5+ pub fn hostname ( ) -> String {
6+ #[ cfg( unix) ]
7+ {
8+ nix:: unistd:: gethostname ( )
9+ . map ( |h| h. to_string_lossy ( ) . to_string ( ) )
10+ . unwrap_or_else ( |_| "unknown" . into ( ) )
11+ }
12+
13+ #[ cfg( windows) ]
14+ {
15+ std:: env:: var ( "COMPUTERNAME" ) . unwrap_or_else ( |_| "unknown" . into ( ) )
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -39,9 +39,7 @@ impl LockGuard {
3939
4040/// Acquire an advisory lock on the repository.
4141pub fn acquire_lock ( storage : & dyn StorageBackend ) -> Result < LockGuard > {
42- let hostname = nix:: unistd:: gethostname ( )
43- . map ( |h| h. to_string_lossy ( ) . to_string ( ) )
44- . unwrap_or_else ( |_| "unknown" . into ( ) ) ;
42+ let hostname = crate :: platform:: hostname ( ) ;
4543 let pid = std:: process:: id ( ) as u64 ;
4644
4745 // Prefer backend-native lock APIs when available (e.g. REST server locks).
You can’t perform that action at this time.
0 commit comments