Skip to content

Commit 3d69bbd

Browse files
authored
Fix queue pop error and stat empty repository error (#10248)
* Fix queue pop error and stat empty repository error * Fix error
1 parent 83a8944 commit 3d69bbd

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

modules/indexer/stats/db.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func (db *DBIndexer) Index(id int64) error {
1919
if err != nil {
2020
return err
2121
}
22+
if repo.IsEmpty {
23+
return nil
24+
}
25+
2226
status, err := repo.GetIndexerStatus(models.RepoIndexerTypeStats)
2327
if err != nil {
2428
return err

modules/queue/queue_redis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (fifo *RedisByteFIFO) PushFunc(data []byte, fn func() error) error {
121121
// Pop pops data from the start of the fifo
122122
func (fifo *RedisByteFIFO) Pop() ([]byte, error) {
123123
data, err := fifo.client.LPop(fifo.queueName).Bytes()
124-
if err != nil && err == redis.Nil {
124+
if err == nil || err == redis.Nil {
125125
return data, nil
126126
}
127127
return data, err

modules/queue/unique_queue_redis.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package queue
66

7+
import "github.com/go-redis/redis"
8+
79
// RedisUniqueQueueType is the type for redis queue
810
const RedisUniqueQueueType Type = "unique-redis"
911

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

0 commit comments

Comments
 (0)