mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Generalize BreakUp/RangByChunks functions
This commit is contained in:
parent
c3efc57259
commit
9aa7b80d0d
9 changed files with 58 additions and 59 deletions
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/navidrome/navidrome/core/artwork"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
"github.com/navidrome/navidrome/utils/slice"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
@ -71,7 +70,7 @@ func (r *refresher) flushMap(ctx context.Context, m map[string]struct{}, entity
|
|||
}
|
||||
|
||||
ids := maps.Keys(m)
|
||||
chunks := utils.BreakUpStringSlice(ids, 100)
|
||||
chunks := slice.BreakUp(ids, 100)
|
||||
for _, chunk := range chunks {
|
||||
err := refresh(ctx, chunk...)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/navidrome/navidrome/scanner/metadata"
|
||||
_ "github.com/navidrome/navidrome/scanner/metadata/ffmpeg"
|
||||
_ "github.com/navidrome/navidrome/scanner/metadata/taglib"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
"github.com/navidrome/navidrome/utils/slice"
|
||||
)
|
||||
|
||||
type TagScanner struct {
|
||||
|
@ -351,7 +351,7 @@ func (s *TagScanner) addOrUpdateTracksInDB(
|
|||
|
||||
log.Trace(ctx, "Updating mediaFiles in DB", "dir", dir, "numFiles", len(filesToUpdate))
|
||||
// Break the file list in chunks to avoid calling ffmpeg with too many parameters
|
||||
chunks := utils.BreakUpStringSlice(filesToUpdate, filesBatchSize)
|
||||
chunks := slice.BreakUp(filesToUpdate, filesBatchSize)
|
||||
for _, chunk := range chunks {
|
||||
// Load tracks Metadata from the folder
|
||||
newTracks, err := s.loadTracks(chunk)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue