Refactor string utilities into its own package str

This commit is contained in:
Deluan 2024-06-05 22:09:27 -04:00
parent 46fc38bf61
commit abe5690018
16 changed files with 158 additions and 125 deletions

View file

@ -5,7 +5,7 @@ import (
"database/sql"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/utils"
"github.com/navidrome/navidrome/utils/str"
"github.com/pressly/goose/v3"
)
@ -50,7 +50,7 @@ select a.id, a.name, a.artist_id, a.album_artist_id, group_concat(mf.artist_id,
if err != nil {
return err
}
all := utils.SanitizeStrings(artistId, albumArtistId, songArtistIds.String)
all := str.SanitizeStrings(artistId, albumArtistId, songArtistIds.String)
_, err = stmt.Exec(all, id)
if err != nil {
log.Error("Error setting album's artist_ids", "album", name, "albumId", id, err)

View file

@ -5,7 +5,7 @@ import (
"database/sql"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/utils"
"github.com/navidrome/navidrome/utils/str"
"github.com/pressly/goose/v3"
)
@ -33,8 +33,8 @@ func upUnescapeLyricsAndComments(_ context.Context, tx *sql.Tx) error {
return err
}
newComment := utils.SanitizeText(comment.String)
newLyrics := utils.SanitizeText(lyrics.String)
newComment := str.SanitizeText(comment.String)
newLyrics := str.SanitizeText(lyrics.String)
_, err = stmt.Exec(newComment, newLyrics, id)
if err != nil {
log.Error("Error unescaping media_file's lyrics and comments", "title", title, "id", id, err)