Skip to content

Commit

Permalink
Fix queue pop error and stat empty repository error (go-gitea#10248)
Browse files Browse the repository at this point in the history
* Fix queue pop error and stat empty repository error

* Fix error
  • Loading branch information
lunny authored Feb 12, 2020
1 parent 83a8944 commit 3d69bbd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions modules/indexer/stats/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (db *DBIndexer) Index(id int64) error {
if err != nil {
return err
}
if repo.IsEmpty {
return nil
}

status, err := repo.GetIndexerStatus(models.RepoIndexerTypeStats)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion modules/queue/queue_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (fifo *RedisByteFIFO) PushFunc(data []byte, fn func() error) error {
// Pop pops data from the start of the fifo
func (fifo *RedisByteFIFO) Pop() ([]byte, error) {
data, err := fifo.client.LPop(fifo.queueName).Bytes()
if err != nil && err == redis.Nil {
if err == nil || err == redis.Nil {
return data, nil
}
return data, err
Expand Down
4 changes: 3 additions & 1 deletion modules/queue/unique_queue_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package queue

import "github.com/go-redis/redis"

// RedisUniqueQueueType is the type for redis queue
const RedisUniqueQueueType Type = "unique-redis"

Expand Down Expand Up @@ -102,7 +104,7 @@ func (fifo *RedisUniqueByteFIFO) PushFunc(data []byte, fn func() error) error {
// Pop pops data from the start of the fifo
func (fifo *RedisUniqueByteFIFO) Pop() ([]byte, error) {
data, err := fifo.client.LPop(fifo.queueName).Bytes()
if err != nil {
if err != nil && err != redis.Nil {
return data, err
}

Expand Down

0 comments on commit 3d69bbd

Please sign in to comment.