diff --git a/downloader/downloader.go b/downloader/downloader.go index 2fe9578..03d3582 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -260,6 +260,7 @@ func (d *Downloader) createImage(item *LibraryItem, filePath string) error { }) } else { log.Printf("Skipping '%v' [saved as '%v']", item.Filename, item.UsedFileName) + d.stats.UpdateStatsSkipped(1) } return nil } @@ -331,11 +332,11 @@ func (d *Downloader) DownloadAll(svc *photoslibrary.Service) error { } if hasMore { - log.Printf("Processed: %v, Downloaded: %v, Errors: %v, Total Size: %v", d.stats.Total, d.stats.Downloaded, d.stats.Errors, humanize.Bytes(d.stats.TotalSize)) + log.Printf("Processed: %v, Downloaded: %v, Skipped: %v, Errors: %v, Total Size: %v", d.stats.Total, d.stats.Downloaded, d.stats.Skipped, d.stats.Errors, humanize.Bytes(d.stats.TotalSize)) time.Sleep(sleepTime) } } - log.Printf("Finished: %v, Downloaded: %v, Errors: %v, Total Size: %v", d.stats.Total, d.stats.Downloaded, d.stats.Errors, humanize.Bytes(d.stats.TotalSize)) + log.Printf("Finished: %v, Downloaded: %v, Skipped: %v, Errors: %v, Total Size: %v", d.stats.Total, d.stats.Downloaded, d.stats.Skipped, d.stats.Errors, humanize.Bytes(d.stats.TotalSize)) return nil } diff --git a/downloader/stats.go b/downloader/stats.go index aa89ee8..0407843 100644 --- a/downloader/stats.go +++ b/downloader/stats.go @@ -6,15 +6,16 @@ import ( // Stats TODO type Stats struct { - Total int - Errors int - TotalSize uint64 + Total int + Errors int + TotalSize uint64 Downloaded int + Skipped int mutex sync.Mutex } -// UpdateStatsTotal TODO +// UpdateStatsTotal increment the total items func (s *Stats) UpdateStatsTotal(total int) { s.mutex.Lock() defer s.mutex.Unlock() @@ -22,7 +23,7 @@ func (s *Stats) UpdateStatsTotal(total int) { s.Total += total } -// UpdateStatsDownloaded TODO +// UpdateStatsDownloaded increment the downloaded items and size of items func (s *Stats) UpdateStatsDownloaded(totalSize uint64, downloaded int) { s.mutex.Lock() defer s.mutex.Unlock() @@ -31,10 +32,18 @@ func (s *Stats) UpdateStatsDownloaded(totalSize uint64, downloaded int) { s.Downloaded += downloaded } -// UpdateStatsError TODO +// UpdateStatsError increment the items that produced errors func (s *Stats) UpdateStatsError(errors int) { s.mutex.Lock() defer s.mutex.Unlock() s.Errors += errors -} \ No newline at end of file +} + +// UpdateStatsError increment the skipped items +func (s *Stats) UpdateStatsSkipped(skipped int) { + s.mutex.Lock() + defer s.mutex.Unlock() + + s.Skipped += skipped +}