From 18de1ba08dda516625f7156aa6f3a4461144256c Mon Sep 17 00:00:00 2001 From: Avery Date: Thu, 2 Jan 2025 09:10:04 -0600 Subject: [PATCH 1/2] Fix AccuRip test that can vary with changes in the database Signed-off-by: Avery --- whipper/test/test_common_accurip.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/whipper/test/test_common_accurip.py b/whipper/test/test_common_accurip.py index 32914244..2688b72b 100644 --- a/whipper/test/test_common_accurip.py +++ b/whipper/test/test_common_accurip.py @@ -42,8 +42,10 @@ def test_AccurateRipResponse_parses_correctly(self): self.assertEqual(responses[1].discId1, '0000f21c') self.assertEqual(responses[1].discId2, '00027ef8') self.assertEqual(responses[1].cddbDiscId, '05021002') - self.assertEqual(responses[1].confidences[0], 7) - self.assertEqual(responses[1].confidences[1], 7) + # The following two values may increase in the Accurip database over time; + # both are 9 as retrieved on 2025-01-02 + self.assertGreaterEqual(responses[1].confidences[0], 9) + self.assertGreaterEqual(responses[1].confidences[1], 9) self.assertEqual(responses[1].checksums[0], 'dc77f9ab') self.assertEqual(responses[1].checksums[1], 'dd97d2c3') From 12c6688a16cee0ee9787979e7020b7a60fe549e0 Mon Sep 17 00:00:00 2001 From: Avery Date: Thu, 2 Jan 2025 09:10:29 -0600 Subject: [PATCH 2/2] Warn about offset > 587 only after the rip fails with size 0: Upstream cd-paranoia fixed the offset issue, but we can't check whether the installed version contains the fix. Instead of warning everyone before the rip starts, warn only the people who get an empty file with the large offset. Don't show size mismatch warnings for zero-size files Signed-off-by: Avery --- whipper/program/cdparanoia.py | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/whipper/program/cdparanoia.py b/whipper/program/cdparanoia.py index 5c4b7793..570c2d6e 100644 --- a/whipper/program/cdparanoia.py +++ b/whipper/program/cdparanoia.py @@ -283,17 +283,6 @@ def start(self, runner): stopTrack, common.framesToHMSF(stopOffset)), self.path]) logger.debug('running %s', (" ".join(argv), )) - if self._offset > 587: - logger.warning( - "because of a cd-paranoia upstream bug whipper may fail to " - "work correctly when using offset values > 587 (current " - "value: %d) and print warnings like this: 'file size 0 did " - "not match expected size'. For more details please check the " - "following issues: " - "https://github.com/whipper-team/whipper/issues/234 and " - "https://github.com/rocky/libcdio-paranoia/issues/14", - self._offset - ) if stopTrack == 99: logger.warning( "because of a cd-paranoia upstream bug whipper may fail to " @@ -372,9 +361,26 @@ def _done(self): # check if the length matches size = os.stat(self.path)[stat.ST_SIZE] # wav header is 44 bytes - offsetLength = self._stop - self._start + 1 - expected = offsetLength * common.BYTES_PER_FRAME + 44 - if size != expected: + frameCount = self._stop - self._start + 1 + expected = frameCount * common.BYTES_PER_FRAME + 44 + if size == 0: + + if self._offset > 587: + logger.warning( + "file is empty, possibly because of a cd-paranoia upstream " + "bug when using offset values > 587 (current value: %d). " + "For more details please check the following issues: " + "https://github.com/whipper-team/whipper/issues/234 and " + "https://github.com/rocky/libcdio-paranoia/issues/14", + self._offset + ) + else: + logger.warning('file is empty') + self.setAndRaiseException(FileSizeError(self.path, + "File is empty, " + "expected size %d" % ( + expected ))) + elif size != expected: # FIXME: handle errors better logger.warning('file size %d did not match expected size %d', size, expected) @@ -399,7 +405,7 @@ def _done(self): self.quality = self._parser.getTrackQuality() self.duration = end_time - self._start_time - self.speed = (offsetLength / 75.0) / self.duration + self.speed = (frameCount / 75.0) / self.duration self.stop() return