Skip to content

Commit

Permalink
Fix #535 - some CLI commands duplicate comment tag info
Browse files Browse the repository at this point in the history
  • Loading branch information
mherger committed Apr 10, 2022
1 parent e694238 commit f36028f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog8.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h2><a name="v8.3.0" id="v8.3.0"></a>Version 8.3.0</h2>
<li>Improve Deezer metadata lookup when adding albums/playlists through the CLI.</li>
<li><a href="https://github.com/andygrundman/Audio-Scan/issues/9">(Audio::Scan) #9</a> - For some WavPack DSD file the song_length_ms is incorrect (thanks aeeq & ralphy!)</li>
<li><a href="https://github.com/andygrundman/Audio-Scan/pulls/12">(Audio::Scan) #12</a> - ID3: Fix v2.4 extended header handling (thanks mw9 & ralphy!)</li>
<li><a href="https://github.com/Logitech/slimserver/issues/535">#535</a> - some CLI commands duplicate comment tag info</li>
<li><a href="https://github.com/Logitech/slimserver/issues/547">#547</a> - duplicate albums after adding tracks while renaming album</li>
<li><a href="https://github.com/Logitech/slimserver/pull/668">#668</a> - Podcasts: Pre-caching image and more-info data can bring the server to a crawl #668 (thanks mw9!)</li>
<li>Fix image transformation if a cover requested using /current/cover is pointing to a local file.</li>
Expand Down
19 changes: 14 additions & 5 deletions Slim/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1386,22 +1386,31 @@ sub _createYear {
}
}
sub _createComments {
my ($self, $comments, $trackId) = @_;
my ($self, $comments, $trackId, $create) = @_;

if ( $comments ) {
# Using native DBI here to improve performance during scanning
my $dbh = Slim::Schema->dbh;

if (!$create) {
my $sth_delete = $dbh->prepare_cached( qq{
DELETE FROM comments
WHERE track = ?
} );

$sth_delete->execute( $trackId );
}

# Add comments if we have them:
my $sth = $dbh->prepare_cached( qq{
REPLACE INTO comments
my $sth_insert = $dbh->prepare_cached( qq{
INSERT INTO comments
(track, value)
VALUES
(?, ?)
} );

for my $comment (@{$comments}) {
$sth->execute( $trackId, $comment );
$sth_insert->execute( $trackId, $comment );

main::DEBUGLOG && $log->is_debug && $log->debug("-- Track has comment '$comment'");
}
Expand Down Expand Up @@ -1688,7 +1697,7 @@ sub _newTrack {
$self->_createGenre($deferredAttributes->{'GENRE'}, $trackId, 1);

### Create Comment rows
$self->_createComments($deferredAttributes->{'COMMENT'}, $trackId);
$self->_createComments($deferredAttributes->{'COMMENT'}, $trackId, 1);

$self->forceCommit if $args->{'commit'};

Expand Down

0 comments on commit f36028f

Please sign in to comment.