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 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')