diff --git a/database/mysql.go b/database/mysql.go index cc30ee9..3d48d81 100644 --- a/database/mysql.go +++ b/database/mysql.go @@ -221,8 +221,8 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error { res, err := m.connection.ExecContext(ctx, ` UPDATE `+m.tableName+` SET - id=? title=? authors=? sortauthor=? isbn10=? isbn13=? format=? genre=? publisher=? - series=? volume=? year=? signed=? description=? notes=? coverurl=? childrens=? + title=?, authors=?, sortauthor=?, isbn10=?, isbn13=?, format=?, genre=?, publisher=?, + series=?, volume=?, year=?, signed=?, description=?, notes=?, coverurl=?, childrens=? WHERE id=?`, new.Title, strings.Join(new.Authors, ";"), new.SortAuthor, new.ISBN10, new.ISBN13, new.Format, new.Genre, new.Publisher, new.Series, new.Volume, new.Year, new.Signed, new.Description, new.Notes, new.CoverURL, new.Childrens, old.ID, diff --git a/database/records.go b/database/records.go index add71c7..e9c87fc 100644 --- a/database/records.go +++ b/database/records.go @@ -100,6 +100,7 @@ func (c *DiscogsCache) loadRecordsFromFS(ctx context.Context) ([]media.Record, t if err != nil { return nil, time.Time{}, fmt.Errorf("error opening cache file %s: %w", c.persistFile, err) } + defer f.Close() err = gob.NewDecoder(f).Decode(p) if err != nil { return nil, time.Time{}, fmt.Errorf("error readhing from cache file %s: %w", c.persistFile, err) @@ -120,6 +121,7 @@ func (c *DiscogsCache) saveRecordsToCache(ctx context.Context, records []media.R if err != nil { return fmt.Errorf("error opening cache file %s: %w", c.persistFile, err) } + defer f.Close() err = gob.NewEncoder(f).Encode(p) if err != nil { return fmt.Errorf("error writing to cache file %s: %w", c.persistFile, err) diff --git a/query/openlibrary.go b/query/openlibrary.go index f61b95c..253bdf3 100644 --- a/query/openlibrary.go +++ b/query/openlibrary.go @@ -39,8 +39,8 @@ func getPublisher(publishers []client.Publishers) string { func getAuthors(authors []client.Authors) []string { ret := make([]string, len(authors)) - for _, author := range authors { - ret = append(ret, author.Name) + for i, author := range authors { + ret[i] = author.Name } return ret }