|
@@ -56,28 +56,17 @@ func watchEmojis() {
|
|
go func() {
|
|
go func() {
|
|
defer logging.Recover()
|
|
defer logging.Recover()
|
|
|
|
|
|
- var (
|
|
|
|
- timer *time.Timer
|
|
|
|
- lastEvent fsnotify.Event
|
|
|
|
- )
|
|
|
|
- timer = time.NewTimer(100 * time.Millisecond)
|
|
|
|
|
|
+ timer := time.NewTimer(100 * time.Millisecond)
|
|
<-timer.C // timer should be expired at first
|
|
<-timer.C // timer should be expired at first
|
|
|
|
|
|
for {
|
|
for {
|
|
select {
|
|
select {
|
|
- case event, ok := <-emojisWatcher.Events:
|
|
|
|
|
|
+ case _, ok := <-emojisWatcher.Events:
|
|
if !ok {
|
|
if !ok {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- lastEvent = event
|
|
|
|
timer.Reset(time.Millisecond * 100)
|
|
timer.Reset(time.Millisecond * 100)
|
|
-
|
|
|
|
- if lastEvent.Op&fsnotify.Rename == fsnotify.Rename || lastEvent.Op&fsnotify.Write == fsnotify.Write {
|
|
|
|
- util.PushReloadEmojiConf()
|
|
|
|
- } else if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
|
|
|
|
- util.PushReloadEmojiConf()
|
|
|
|
- }
|
|
|
|
case err, ok := <-emojisWatcher.Errors:
|
|
case err, ok := <-emojisWatcher.Errors:
|
|
if !ok {
|
|
if !ok {
|
|
return
|
|
return
|
|
@@ -85,11 +74,7 @@ func watchEmojis() {
|
|
logging.LogErrorf("watch emojis failed: %s", err)
|
|
logging.LogErrorf("watch emojis failed: %s", err)
|
|
case <-timer.C:
|
|
case <-timer.C:
|
|
//logging.LogInfof("emojis changed: %s", lastEvent)
|
|
//logging.LogInfof("emojis changed: %s", lastEvent)
|
|
- if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
|
|
|
|
- util.PushReloadEmojiConf()
|
|
|
|
- } else {
|
|
|
|
- util.PushReloadEmojiConf()
|
|
|
|
- }
|
|
|
|
|
|
+ util.PushReloadEmojiConf()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
}()
|