mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-02 12:26:36 +08:00
Improve large library storage backends and scans
This commit is contained in:
@@ -144,13 +144,17 @@ func statsLibrariesHandler(svc *service.Container) gin.HandlerFunc {
|
||||
if !service.LibraryVisibleForUser(c.Request.Context(), svc.Repo, l, visibility) {
|
||||
continue
|
||||
}
|
||||
libraryIDs, err := service.MergedLibraryIDsForLibrary(c.Request.Context(), svc.Repo, l.ID)
|
||||
if err != nil || len(libraryIDs) == 0 {
|
||||
libraryIDs = []string{l.ID}
|
||||
}
|
||||
var count int64
|
||||
var size int64
|
||||
_ = applyMediaVisibilityQuery(svc.Repo.DB.Model(&model.Media{}), visibility).
|
||||
Where("library_id = ?", l.ID).
|
||||
Where("library_id IN ?", libraryIDs).
|
||||
Count(&count).Error
|
||||
_ = applyMediaVisibilityQuery(svc.Repo.DB.Model(&model.Media{}), visibility).
|
||||
Where("library_id = ?", l.ID).
|
||||
Where("library_id IN ?", libraryIDs).
|
||||
Select("COALESCE(SUM(size_bytes),0)").Row().Scan(&size)
|
||||
out = append(out, gin.H{
|
||||
"library": l,
|
||||
|
||||
Reference in New Issue
Block a user