@@ -38,6 +38,7 @@ type SharedState struct {
3838 //main thread after waiting on the writing thread), so no additional
3939 //locking is required for these fields
4040 DirectoriesScanned uint64
41+ DirectoriesFailed uint64
4142 FilesFound uint64
4243 FilesFailed uint64
4344 FilesTransferred uint64
@@ -73,7 +74,7 @@ func Run(state *SharedState) (exitCode int) {
7374 Gauge ("last_run.files_found" , int64 (state .FilesFound ), 1.0 )
7475 Gauge ("last_run.files_transfered" , int64 (state .FilesTransferred ), 1.0 )
7576 Gauge ("last_run.files_failed" , int64 (state .FilesFailed ), 1.0 )
76- if state .FilesFailed > 0 {
77+ if state .FilesFailed > 0 || state . DirectoriesFailed > 0 {
7778 Gauge ("last_run.success" , 0 , 1.0 )
7879 exitCode = 1
7980 } else {
@@ -82,9 +83,11 @@ func Run(state *SharedState) (exitCode int) {
8283 }
8384
8485 //report results
85- Log (LogInfo , "%d dirs scanned, %d files found, %d transferred, %d failed" ,
86- state .DirectoriesScanned , state .FilesFound ,
87- state .FilesTransferred , state .FilesFailed ,
86+ Log (LogInfo , "%d dirs scanned, %d failed" ,
87+ state .DirectoriesScanned , state .DirectoriesFailed ,
88+ )
89+ Log (LogInfo , "%d files found, %d transferred, %d failed" ,
90+ state .FilesFound , state .FilesTransferred , state .FilesFailed ,
8891 )
8992
9093 return
@@ -100,6 +103,7 @@ func makeScraperThread(state *SharedState) <-chan File {
100103 defer state .WaitGroup .Done ()
101104 defer close (out )
102105
106+ var directoriesFailed uint64
103107 var directoriesScanned uint64
104108 var filesFound uint64
105109
@@ -112,14 +116,19 @@ func makeScraperThread(state *SharedState) <-chan File {
112116 break
113117 }
114118
115- for _ , file := range scraper .Next () {
119+ files , countAsFailed := scraper .Next ()
120+ for _ , file := range files {
116121 filesFound ++
117122 out <- file
118123 }
119124 directoriesScanned ++
125+ if countAsFailed {
126+ directoriesFailed ++
127+ }
120128 }
121129
122130 //submit statistics to main thread
131+ state .DirectoriesFailed = directoriesFailed
123132 state .DirectoriesScanned = directoriesScanned
124133 state .FilesFound = filesFound
125134 }()
0 commit comments