thomasvs / morituri

For those about to RIP - a Unix CD ripper preferring accuracy over speed
GNU General Public License v3.0
301 stars 42 forks source link

use offset when caching TOC info #92

Open drhuettl opened 10 years ago

drhuettl commented 10 years ago

Forces recalculation of the TOC info when using a drive with a different offset.

JoeLametta commented 8 years ago

This pull request makes morituri hang on rip cd info with the following traceback:

Traceback (most recent call last):
File "/home/rasty/projects/morituri/bin/rip", line 41, in <module>
sys.exit(main.main(sys.argv[1:]))
File "/home/rasty/projects/morituri/morituri/rip/main.py", line 45, in main
ret = c.parse(argv)
File "/home/rasty/projects/morituri/morituri/rip/main.py", line 123, in parse
logcommand.LogCommand.parse(self, argv)
File "/home/rasty/projects/morituri/morituri/common/logcommand.py", line 62, in parse
command.Command.parse(self, argv)
File "/home/rasty/projects/morituri/morituri/extern/command/command.py", line 401, in parse
return self.subCommands[command].parse(args[1:])
File "/home/rasty/projects/morituri/morituri/common/logcommand.py", line 62, in parse
command.Command.parse(self, argv)
File "/home/rasty/projects/morituri/morituri/extern/command/command.py", line 401, in parse
return self.subCommands[command].parse(args[1:])
File "/home/rasty/projects/morituri/morituri/common/logcommand.py", line 62, in parse
command.Command.parse(self, argv)
File "/home/rasty/projects/morituri/morituri/extern/command/command.py", line 363, in parse
ret = self.do(args)
File "/home/rasty/projects/morituri/morituri/rip/cd.py", line 120, in do
self.ittoc.getMusicBrainzDiscId(), self.device, self.options.offset)
AttributeError: Values instance has no attribute 'offset'

This is a temporary ugly fix which solves this bug:

--- cd.py
+++ cd_fix.py
@@ -113,11 +113,19 @@
                     self.program.ejectDevice(self.device)
                 return -1

-        # now, read the complete index table, which is slower
+        # Ugly fix for broken commit
+        offset = 0
+        info = drive.getDeviceInfo(self.parentCommand.options.device)
+        if info:
+            try:
+                offset = self.getRootCommand().config.getReadOffset(*info)
+            except KeyError:
+                pass

+        # now, read the complete index table, which is slower
         self.itable = self.program.getTable(self.runner,
             self.ittoc.getCDDBDiscId(),
-            self.ittoc.getMusicBrainzDiscId(), self.device, self.options.offset)
+            self.ittoc.getMusicBrainzDiscId(), self.device, offset)

         assert self.itable.getCDDBDiscId() == self.ittoc.getCDDBDiscId(), \
             "full table's id %s differs from toc id %s" % (