mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-11 02:36:28 +00:00
When setting wait to true, we wait until the populating isn't in progress anymore. This is used on startup connections where we really need the initial information which could take a long time on big servers.
This commit is contained in:
@ -85,15 +85,18 @@ func (b *Bslack) populateUser(userID string) {
|
||||
b.usersMutex.Unlock()
|
||||
}
|
||||
|
||||
func (b *Bslack) populateUsers() {
|
||||
func (b *Bslack) populateUsers(wait bool) {
|
||||
b.refreshMutex.Lock()
|
||||
if time.Now().Before(b.earliestUserRefresh) || b.refreshInProgress {
|
||||
if !wait && (time.Now().Before(b.earliestUserRefresh) || b.refreshInProgress) {
|
||||
b.Log.Debugf("Not refreshing user list as it was done less than %v ago.",
|
||||
minimumRefreshInterval)
|
||||
b.refreshMutex.Unlock()
|
||||
|
||||
return
|
||||
}
|
||||
for b.refreshInProgress {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
b.refreshInProgress = true
|
||||
b.refreshMutex.Unlock()
|
||||
|
||||
@ -129,14 +132,17 @@ func (b *Bslack) populateUsers() {
|
||||
b.refreshInProgress = false
|
||||
}
|
||||
|
||||
func (b *Bslack) populateChannels() {
|
||||
func (b *Bslack) populateChannels(wait bool) {
|
||||
b.refreshMutex.Lock()
|
||||
if time.Now().Before(b.earliestChannelRefresh) || b.refreshInProgress {
|
||||
if !wait && (time.Now().Before(b.earliestChannelRefresh) || b.refreshInProgress) {
|
||||
b.Log.Debugf("Not refreshing channel list as it was done less than %v seconds ago.",
|
||||
minimumRefreshInterval)
|
||||
b.refreshMutex.Unlock()
|
||||
return
|
||||
}
|
||||
for b.refreshInProgress {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
b.refreshInProgress = true
|
||||
b.refreshMutex.Unlock()
|
||||
|
||||
|
Reference in New Issue
Block a user