[mb-commits] branch, master, updated. MBS-5265, don' t include the old release id in Release Group Set Cover Art edi...

MusicBrainz Git Server <[email protected]>
Newsgroups gmane.comp.audio.musicbrainz.cvs
Message-ID <E1TczWx-0006yM-AD@wiley>
The branch, master has been updated
       via  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=996b98e04cea6273affa1b7f0cccb4a79a4807d7 (commit)
      from  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=0aba31b680eae3536cd26ddbbeb3ac3eed372b44 (commit)

Summary of changes:
 lib/MusicBrainz/Server/Data/ReleaseGroup.pm        |   10 ++++++++++
 .../Server/Edit/ReleaseGroup/SetCoverArt.pm        |    5 +++--
 .../Server/Edit/ReleaseGroup/SetCoverArt.pm        |    1 +
 t/sql/caa.sql                                      |    2 +-
 4 files changed, 15 insertions(+), 3 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 996b98e04cea6273affa1b7f0cccb4a79a4807d7
Author: warp <[email protected]>
Date:   Mon Nov 26 15:17:57 2012 +0100

    MBS-5265, don't include the old release id in Release Group Set Cover Art edits if it was automatically picked.

diff --git a/lib/MusicBrainz/Server/Data/ReleaseGroup.pm b/lib/MusicBrainz/Server/Data/ReleaseGroup.pm
index 0095e47..cbb0034 100644
--- a/lib/MusicBrainz/Server/Data/ReleaseGroup.pm
+++ b/lib/MusicBrainz/Server/Data/ReleaseGroup.pm
@@ -604,6 +604,16 @@ sub load_meta
     }, @_);
 }
 
+sub has_cover_art_set
+{
+    my ($self, $rg_id) = @_;
+
+    my $query = "SELECT release
+            FROM cover_art_archive.release_group_cover_art
+            WHERE release_group = ?";
+
+    return $self->sql->select_single_value ($query, $rg_id);
+}
 
 sub set_cover_art {
     my ($self, $rg_id, $release_id) = @_;
diff --git a/lib/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm b/lib/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm
index 20b6c7c..8cba72c 100644
--- a/lib/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm
+++ b/lib/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm
@@ -55,9 +55,10 @@ sub initialize {
     my %old;
     my %new = ( release_id => $opts{release}->id );
 
-    if ($opts{entity}->cover_art && $opts{entity}->cover_art->release)
+    if ($rg->cover_art && $rg->cover_art->release
+        && $self->c->model('ReleaseGroup')->has_cover_art_set ($rg->id))
     {
-        $old{release_id} = $opts{entity}->cover_art->release->id;
+        $old{release_id} = $rg->cover_art->release->id;
     }
 
     $self->data({
diff --git a/t/lib/t/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm b/t/lib/t/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm
index 0068575..a999451 100644
--- a/t/lib/t/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm
+++ b/t/lib/t/MusicBrainz/Server/Edit/ReleaseGroup/SetCoverArt.pm
@@ -77,3 +77,4 @@ test 'Set cover art fails if release no longer exists' => sub {
         "... and is a failed dependancy");
 };
 
+1;
diff --git a/t/sql/caa.sql b/t/sql/caa.sql
index ea9f7ff..ca8c78b 100644
--- a/t/sql/caa.sql
+++ b/t/sql/caa.sql
@@ -20,8 +20,8 @@ INSERT INTO release (id, gid, name, artist_credit, release_group)
   VALUES (1, '14b9d183-7dab-42ba-94a3-7388a66604b8', 1, 1, 1);
 
 INSERT INTO edit (id, editor, type, data, status, expire_time) VALUES (1, 10, 316, '', 2, now());
-INSERT INTO cover_art_archive.cover_art (id, release, edit, ordering) VALUES (12345, 1, 1, 1);
 INSERT INTO cover_art_archive.art_type (id, name) VALUES (1, 'Front');
+INSERT INTO cover_art_archive.cover_art (id, release, edit, ordering) VALUES (12345, 1, 1, 1);
 INSERT INTO cover_art_archive.cover_art_type (id, type_id) VALUES (12345, 1);
 
 ALTER SEQUENCE edit_id_seq RESTART 2;

-----------------------------------------------------------------------


hooks/post-receive
-- 
mb_server
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.