Remove duplicated helper functions, move them to utils package
This commit is contained in:
@@ -2,7 +2,6 @@ package persistence
|
||||
|
||||
import (
|
||||
"context"
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -16,6 +15,7 @@ import (
|
||||
"github.com/deluan/navidrome/consts"
|
||||
"github.com/deluan/navidrome/log"
|
||||
"github.com/deluan/navidrome/model"
|
||||
"github.com/deluan/navidrome/utils"
|
||||
"github.com/deluan/rest"
|
||||
)
|
||||
|
||||
@@ -222,7 +222,7 @@ func getCoverFromPath(path string, hasEmbeddedCover bool) string {
|
||||
|
||||
for _, name := range names {
|
||||
match, _ := filepath.Match(pat, strings.ToLower(name))
|
||||
if match && isImageFile(filepath.Ext(name)) {
|
||||
if match && utils.IsImageFile(name) {
|
||||
return filepath.Join(filepath.Dir(path), name)
|
||||
}
|
||||
}
|
||||
@@ -231,10 +231,6 @@ func getCoverFromPath(path string, hasEmbeddedCover bool) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func isImageFile(extension string) bool {
|
||||
return strings.HasPrefix(mime.TypeByExtension(extension), "image/")
|
||||
}
|
||||
|
||||
func (r *albumRepository) purgeEmpty() error {
|
||||
del := Delete(r.tableName).Where("id not in (select distinct(album_id) from media_file)")
|
||||
c, err := r.executeSQL(del)
|
||||
|
||||
Reference in New Issue
Block a user