()
| 985 | } |
| 986 | |
| 987 | func (cs *copyStatus) String() string { |
| 988 | var buf bytes.Buffer |
| 989 | now := time.Now() |
| 990 | buf.WriteString(cs.sb.Ref.String()) |
| 991 | buf.WriteString(": ") |
| 992 | |
| 993 | cs.mu.Lock() |
| 994 | defer cs.mu.Unlock() |
| 995 | sinceStart := now.Sub(cs.start) |
| 996 | sinceLast := now.Sub(cs.t) |
| 997 | |
| 998 | switch cs.state { |
| 999 | case statusReading: |
| 1000 | buf.WriteString(cs.state) |
| 1001 | fmt.Fprintf(&buf, " (%d/%dB)", cs.nread, cs.sb.Size) |
| 1002 | case statusWriting: |
| 1003 | if cs.nwrite == cs.sb.Size { |
| 1004 | buf.WriteString("wrote all, waiting ack") |
| 1005 | } else { |
| 1006 | buf.WriteString(cs.state) |
| 1007 | fmt.Fprintf(&buf, " (%d/%dB)", cs.nwrite, cs.sb.Size) |
| 1008 | } |
| 1009 | default: |
| 1010 | buf.WriteString(cs.state) |
| 1011 | |
| 1012 | } |
| 1013 | if sinceLast > 5*time.Second { |
| 1014 | fmt.Fprintf(&buf, ", last change %v ago (total elapsed %v)", sinceLast, sinceStart) |
| 1015 | } |
| 1016 | return buf.String() |
| 1017 | } |
| 1018 | |
| 1019 | type failDetail struct { |
| 1020 | when time.Time |
no test coverage detected