Fixed avatar downloader
This commit is contained in:
parent
c729d9d3ba
commit
3eaf1c714e
@ -6,6 +6,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "image/gif"
|
_ "image/gif"
|
||||||
@ -24,6 +25,7 @@ const (
|
|||||||
var avatarSources []AvatarSource
|
var avatarSources []AvatarSource
|
||||||
var avatarOutputs []AvatarOutput
|
var avatarOutputs []AvatarOutput
|
||||||
var avatarLog = log.New()
|
var avatarLog = log.New()
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
func main() {
|
func main() {
|
||||||
@ -88,14 +90,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Worker queue
|
// Worker queue
|
||||||
usersQueue := make(chan *arn.User, 512)
|
usersQueue := make(chan *arn.User, runtime.NumCPU())
|
||||||
StartWorkers(usersQueue, Work)
|
StartWorkers(usersQueue, Work)
|
||||||
|
|
||||||
// We'll send each user to one of the worker threads
|
// We'll send each user to one of the worker threads
|
||||||
for user := range arn.MustStreamUsers() {
|
for user := range arn.MustStreamUsers() {
|
||||||
|
wg.Add(1)
|
||||||
usersQueue <- user
|
usersQueue <- user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
color.Green("Finished.")
|
color.Green("Finished.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +117,7 @@ func StartWorkers(queue chan *arn.User, work func(*arn.User)) {
|
|||||||
|
|
||||||
// Work handles a single user.
|
// Work handles a single user.
|
||||||
func Work(user *arn.User) {
|
func Work(user *arn.User) {
|
||||||
|
fmt.Println(user.ID, "|", user.Nick)
|
||||||
user.AvatarExtension = ""
|
user.AvatarExtension = ""
|
||||||
|
|
||||||
for _, source := range avatarSources {
|
for _, source := range avatarSources {
|
||||||
|
Loading…
Reference in New Issue
Block a user