Browse Source

fix-updatetime

pull/110/head
lewis 3 months ago
parent
commit
adb5b94415
1 changed files with 19 additions and 12 deletions
  1. +19
    -12
      models/repo.go

+ 19
- 12
models/repo.go View File

@@ -6,14 +6,12 @@
package models

import (
"code.gitea.io/gitea/modules/blockchain"
"context"
"crypto/md5"
"errors"
"fmt"
"html/template"
"sync"

"code.gitea.io/gitea/modules/blockchain"

// Needed for jpeg support
_ "image/jpeg"
@@ -2409,15 +2407,6 @@ func (repo *Repository) GetTreePathLock(treePath string) (*LFSLock, error) {
return nil, nil
}

var lck sync.Mutex

func (repo *Repository) IncreaseCloneCnt() {
lck.Lock()
defer lck.Unlock()
repo.CloneCnt++
_ = UpdateRepositoryCols(repo, "clone_cnt")
}

func updateRepositoryCols(e Engine, repo *Repository, cols ...string) error {
_, err := e.ID(repo.ID).Cols(cols...).Update(repo)
return err
@@ -2434,3 +2423,21 @@ func GetBlockChainUnSuccessRepos() ([]*Repository, error) {
Where("block_chain_status != ?", RepoBlockChainSuccess).
Find(&repos)
}

func (repo *Repository) IncreaseCloneCnt() {
sess := x.NewSession()
defer sess.Close()

if err := sess.Begin(); err != nil {
return
}
if _, err := sess.Exec("UPDATE `repository` SET clone_cnt = clone_cnt + 1 WHERE id = ?", repo.ID); err != nil {
return
}

if err := sess.Commit(); err != nil {
return
}

return
}

Loading…
Cancel
Save