@@ -12,20 +12,20 @@ use tempfile::TempDir;
12
12
13
13
#[ derive( Debug ) ]
14
14
pub ( crate ) struct Session {
15
- ctl : Option < TempDir > ,
16
- ctl_path : Box < Path > ,
15
+ tempdir : Option < TempDir > ,
16
+ ctl : Box < Path > ,
17
17
addr : Box < str > ,
18
18
master_log : Box < Path > ,
19
19
}
20
20
21
21
impl Session {
22
- pub ( crate ) fn new ( ctl : TempDir , addr : & str ) -> Self {
23
- let log = ctl . path ( ) . join ( "log" ) . into_boxed_path ( ) ;
24
- let ctl_path = ctl . path ( ) . join ( "master" ) . into_boxed_path ( ) ;
22
+ pub ( crate ) fn new ( tempdir : TempDir , addr : & str ) -> Self {
23
+ let log = tempdir . path ( ) . join ( "log" ) . into_boxed_path ( ) ;
24
+ let ctl = tempdir . path ( ) . join ( "master" ) . into_boxed_path ( ) ;
25
25
26
26
Self {
27
- ctl : Some ( ctl ) ,
28
- ctl_path ,
27
+ tempdir : Some ( tempdir ) ,
28
+ ctl ,
29
29
addr : addr. into ( ) ,
30
30
master_log : log,
31
31
}
@@ -35,7 +35,7 @@ impl Session {
35
35
let mut cmd = std:: process:: Command :: new ( "ssh" ) ;
36
36
cmd. stdin ( Stdio :: null ( ) )
37
37
. arg ( "-S" )
38
- . arg ( & * self . ctl_path )
38
+ . arg ( & * self . ctl )
39
39
. arg ( "-o" )
40
40
. arg ( "BatchMode=yes" )
41
41
. args ( args)
@@ -65,6 +65,10 @@ impl Session {
65
65
}
66
66
}
67
67
68
+ pub ( crate ) fn ctl ( & self ) -> & Path {
69
+ & self . ctl
70
+ }
71
+
68
72
pub ( crate ) fn raw_command < S : AsRef < OsStr > > ( & self , program : S ) -> Command {
69
73
// XXX: Should we do a self.check() here first?
70
74
@@ -117,8 +121,8 @@ impl Session {
117
121
pub ( crate ) async fn close ( mut self ) -> Result < ( ) , Error > {
118
122
let mut exit_cmd = self . new_cmd ( & [ "-O" , "exit" ] ) ;
119
123
120
- // Take self.ctl so that drop would do nothing
121
- let ctl = self . ctl . take ( ) . unwrap ( ) ;
124
+ // Take self.tempdir so that drop would do nothing
125
+ let tempdir = self . tempdir . take ( ) . unwrap ( ) ;
122
126
123
127
let exit = exit_cmd. output ( ) . await . map_err ( Error :: Ssh ) ?;
124
128
@@ -148,7 +152,7 @@ impl Session {
148
152
) ) ) ;
149
153
}
150
154
151
- ctl . close ( ) . map_err ( Error :: Cleanup ) ?;
155
+ tempdir . close ( ) . map_err ( Error :: Cleanup ) ?;
152
156
153
157
Ok ( ( ) )
154
158
}
@@ -184,8 +188,8 @@ impl Session {
184
188
impl Drop for Session {
185
189
fn drop ( & mut self ) {
186
190
// Keep tempdir alive until the connection is established
187
- let _ctl = match self . ctl . take ( ) {
188
- Some ( ctl ) => ctl ,
191
+ let _tempdir = match self . tempdir . take ( ) {
192
+ Some ( tempdir ) => tempdir ,
189
193
// return since close must have already been called.
190
194
None => return ,
191
195
} ;
0 commit comments