Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
single-thread staging to avoid potential double commit
Browse files Browse the repository at this point in the history
Change-Id: I309b4440c93858d583d7d719c2f83a9fa3a124fb
  • Loading branch information
theganyo committed Apr 16, 2019
1 parent 7664776 commit 14a99a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions adapter/analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type manager struct {
secret string
sendChannelSize int
closeWait sync.WaitGroup
stageLock sync.Mutex
}

// Start starts the manager.
Expand Down
3 changes: 3 additions & 0 deletions adapter/analytics/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import (

// stageUpload moves anything in the temp dir to the staging dir
func (m *manager) stageUpload() error {
m.stageLock.Lock()
defer m.stageLock.Unlock()

subDirs, err := ioutil.ReadDir(m.tempDir)
if err != nil {
return fmt.Errorf("ReadDir(%s): %s", m.tempDir, err)
Expand Down

0 comments on commit 14a99a9

Please sign in to comment.