From bb724fb211d1bc7902acdce192fb387eb43c0ed7 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Fri, 23 Sep 2022 08:06:49 +0200 Subject: [PATCH] PICARD-2549: Fixed similarity not getting updated if only difference is cover art If a file is moved to a track where the metadata matches perfectly but only cover art is different, then the similarity score of this file was not recalculated. That means the file retains the similarity of the previous (probably bad) match. Also only do this change if the state was NORMAL before (similar to the other state updates, ignoring states like PENDING and ERROR). --- picard/file.py | 10 +++++----- test/test_file.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/picard/file.py b/picard/file.py index 7d143f3a7..5c4a7bee8 100644 --- a/picard/file.py +++ b/picard/file.py @@ -710,12 +710,12 @@ class File(QtCore.QObject, Item): self.state = File.CHANGED break else: - if (self.metadata.images + self.similarity = 1.0 + if self.state in (File.CHANGED, File.NORMAL): + if (self.metadata.images and self.orig_metadata.images != self.metadata.images): - self.state = File.CHANGED - else: - self.similarity = 1.0 - if self.state == File.CHANGED: + self.state = File.CHANGED + else: self.state = File.NORMAL if signal: log.debug("Updating file %r", self) diff --git a/test/test_file.py b/test/test_file.py index 564528059..50a19a6d8 100644 --- a/test/test_file.py +++ b/test/test_file.py @@ -2,7 +2,7 @@ # # Picard, the next-generation MusicBrainz tagger # -# Copyright (C) 2018-2021 Philipp Wolfer +# Copyright (C) 2018-2022 Philipp Wolfer # Copyright (C) 2019-2022 Laurent Monin # Copyright (C) 2021 Bob Swift # Copyright (C) 2021 Sophist-UK @@ -459,7 +459,7 @@ class FileUpdateTest(PicardTestCase): self.file.state = File.NORMAL self.file.update(signal=False) - self.assertEqual(self.file.similarity, self.INVALIDSIMVAL) # it shouldbn't be modified + self.assertEqual(self.file.similarity, 1.0) self.assertEqual(self.file.state, File.CHANGED) def test_signal(self):