Fix fetcher flag usage misplacement.

This commit is contained in:
Stanislav Nikitin 2020-11-29 19:36:04 +05:00
parent afad4f5d7f
commit de5b55da43
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
1 changed files with 4 additions and 4 deletions

View File

@ -19,6 +19,10 @@ func (a *Application) fetch() {
return
}
a.fetchIsRunningMutex.Lock()
a.fetchIsRunning = true
a.fetchIsRunningMutex.Unlock()
log.Println("Fetching data for", a.name)
req, err := http.NewRequestWithContext(a.ctx, "GET", a.config.Endpoint, nil)
@ -52,10 +56,6 @@ func (a *Application) fetch() {
a.storage.Put(data)
a.fetchIsRunningMutex.Lock()
a.fetchIsRunning = true
a.fetchIsRunningMutex.Unlock()
a.fetchIsRunningMutex.Lock()
a.fetchIsRunning = false
a.fetchIsRunningMutex.Unlock()