diff options
author | zeripath <art27@cantab.net> | 2021-03-28 04:56:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 05:56:28 +0200 |
commit | 82d1a7fb17ea549b17ef30711e0fa7e136acb880 (patch) | |
tree | ec2311c5d3bd6962f0dc75a3199d9eb440ab8b75 /models | |
parent | 5ad65c8f5d88d9468a479befe42fcec36bf48b26 (diff) | |
download | gitea-82d1a7fb17ea549b17ef30711e0fa7e136acb880.tar.gz gitea-82d1a7fb17ea549b17ef30711e0fa7e136acb880.zip |
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
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/models/repo.go b/models/repo.go index c807916ddc..7f2ec1f742 100644 --- a/models/repo.go +++ b/models/repo.go @@ -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 } |