mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
Update repository size on cron gc task (#15177)
git gc cron could change the size of the repository therefore we should update the size of the repo stored in our database. Also significantly improve the efficiency of counting lfs associated with the repository
This commit is contained in:
1 parent
5ad65c8f5d
commit
82d1a7fb17
2 files changed
+13
-5
No files matched your search
+2
-5
@@ -740,15 +740,12 @@ func (repo *Repository) updateSize(e Engine) error {
|
||||
return fmt.Errorf("updateSize: %v", err)
|
||||
}
|
||||
|
||||
objs, err := repo.GetLFSMetaObjects(-1, 0)
|
||||
lfsSize, err := e.Where("repository_id = ?", repo.ID).SumInt(new(LFSMetaObject), "size")
|
||||
if err != nil {
|
||||
return fmt.Errorf("updateSize: GetLFSMetaObjects: %v", err)
|
||||
}
|
||||
for _, obj := range objs {
|
||||
size += obj.Size
|
||||
}
|
||||
|
||||
repo.Size = size
|
||||
repo.Size = size + lfsSize
|
||||
_, err = e.ID(repo.ID).Cols("size").Update(repo)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user