Skip to content

Commit 5a2ce9b

Browse files
committed
cmd/seriesmeta: Add Unicode normalization for book IDs
1 parent 9546034 commit 5a2ce9b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/seriesmeta/seriesmeta.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
_ "github.com/mattn/go-sqlite3"
1818
"github.com/pgaskin/koboutils/v2/kobo"
1919
"github.com/spf13/pflag"
20+
"golang.org/x/text/unicode/norm"
2021
)
2122

2223
var version = "dev"
@@ -301,7 +302,9 @@ func (k *Kobo) UpdateSeries(log func(filename string, i, total int, series strin
301302

302303
if _, err := tx.Exec(
303304
"INSERT OR REPLACE INTO _seriesmeta (ImageId, Series, SeriesNumber) VALUES (?, ?, ?)",
304-
kobo.ContentIDToImageID(kobo.PathToContentID(relEpub)),
305+
// Normalize the ID to NFC since Kobo runs Linux, meaning database entries use NFC as well.
306+
// Helps with Unicode file names since without this SQLite cannot match values as expected.
307+
norm.NFC.String(kobo.ContentIDToImageID(kobo.PathToContentID(relEpub))),
305308
sql.NullString{String: series, Valid: len(series) > 0},
306309
sql.NullString{String: strconv.FormatFloat(index, 'f', -1, 64), Valid: index > 0},
307310
); err != nil {

0 commit comments

Comments
 (0)