File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,19 @@ func newDebugWrapper(conn io.ReadWriteCloser, w io.Writer) io.ReadWriteCloser {
19
19
func (w * debugWrapper ) Close () error {
20
20
return w .conn .Close ()
21
21
}
22
+
23
+ type debugWrapperR struct {
24
+ rd io.ReadCloser
25
+ io.Reader
26
+ }
27
+
28
+ func newDebugWrapperR (rd io.ReadCloser , w io.Writer ) io.ReadCloser {
29
+ return & debugWrapperR {
30
+ Reader : io .TeeReader (rd , w ),
31
+ rd : rd ,
32
+ }
33
+ }
34
+
35
+ func (w * debugWrapperR ) Close () error {
36
+ return w .rd .Close ()
37
+ }
Original file line number Diff line number Diff line change @@ -263,6 +263,14 @@ func (o *dialOptions) wrapConn(netConn net.Conn) io.ReadWriteCloser {
263
263
return newDebugWrapper (netConn , o .debugOutput )
264
264
}
265
265
266
+ func (o * dialOptions ) wrapStream (rd io.ReadCloser ) io.ReadCloser {
267
+ if o .debugOutput == nil {
268
+ return rd
269
+ }
270
+
271
+ return newDebugWrapperR (rd , o .debugOutput )
272
+ }
273
+
266
274
// Connect is an alias to Dial, for backward compatibility
267
275
func Connect (addr string ) (* ServerConn , error ) {
268
276
return Dial (addr )
@@ -573,7 +581,7 @@ func (c *ServerConn) NameList(path string) (entries []string, err error) {
573
581
}
574
582
}()
575
583
576
- scanner := bufio .NewScanner (r )
584
+ scanner := bufio .NewScanner (c . options . wrapStream ( r ) )
577
585
for scanner .Scan () {
578
586
entries = append (entries , scanner .Text ())
579
587
}
@@ -612,7 +620,7 @@ func (c *ServerConn) List(path string) (entries []*Entry, err error) {
612
620
}
613
621
}()
614
622
615
- scanner := bufio .NewScanner (r )
623
+ scanner := bufio .NewScanner (c . options . wrapStream ( r ) )
616
624
now := time .Now ()
617
625
for scanner .Scan () {
618
626
entry , errParse := parser (scanner .Text (), now , c .options .location )
You can’t perform that action at this time.
0 commit comments