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
}
}
return fmt.Errorf("Repository garbage collection failed in repo: %s: Error: %v", repo.FullName(), err)
}
+
+ // Now update the size of the repository
+ if err := repo.UpdateSize(models.DefaultDBContext()); err != nil {
+ log.Error("Updating size as part of garbage collection failed for %v. Stdout: %s\nError: %v", repo, stdout, err)
+ desc := fmt.Sprintf("Updating size as part of garbage collection failed for %s. Stdout: %s\nError: %v", repo.RepoPath(), stdout, err)
+ if err = models.CreateRepositoryNotice(desc); err != nil {
+ log.Error("CreateRepositoryNotice: %v", err)
+ }
+ return fmt.Errorf("Updating size as part of garbage collection failed in repo: %s: Error: %v", repo.FullName(), err)
+ }
+
return nil
},
); err != nil {