| 129 | } |
| 130 | |
| 131 | func (s *inputStats) Stats() map[string]string { |
| 132 | stats := make(map[string]string) |
| 133 | |
| 134 | processedSize := atomic.LoadInt64(&s.processedSize) |
| 135 | totalSize := atomic.LoadInt64(&s.totalSize) |
| 136 | if totalSize > 0 && processedSize > 0 { |
| 137 | var estimatedEnd time.Time |
| 138 | |
| 139 | now := time.Now() |
| 140 | elapsed := now.Sub(s.beginTime) |
| 141 | speed := float64(elapsed) / float64(processedSize) |
| 142 | estimatedEnd = now.Add(time.Duration(speed * float64(totalSize-processedSize))) |
| 143 | |
| 144 | eta := -time.Since(estimatedEnd) |
| 145 | stats["ETA"] = fmt.Sprint(eta - (eta % time.Second)) |
| 146 | } |
| 147 | |
| 148 | stats["ProcessedFiles"] = fmt.Sprint(atomic.LoadInt64(&s.processedFiles)) |
| 149 | stats["TotalFiles"] = fmt.Sprint(atomic.LoadInt64(&s.totalFiles)) |
| 150 | |
| 151 | return stats |
| 152 | } |
| 153 | |
| 154 | func NewCompressedInput(opener func(fn string) (io.ReadCloser, int64, time.Time, *url.URL, error), sizer func(fn string) (int64, error), done chan bool) *CompressedInput { |
| 155 | s := &CompressedInput{ |