Add assertions for local_filename() in sync module

If we call local_filename(create=False) in the sync
module, by definition we must not get the None value
back (because we only "transfer" files that have been
downloaded). If we get caught returning None in this
case, we know there is something wrong.
This commit is contained in:
Thomas Perl 2009-02-18 21:59:17 +01:00
parent b6b58d0e9d
commit 8dc493effd

View file

@ -206,7 +206,10 @@ class Device(services.ObservableService):
return True
def convert_track(self, episode):
filename = str(episode.local_filename(create=False))
filename = episode.local_filename(create=False)
# The file has to exist, if we ought to transfer it, and therefore,
# local_filename(create=False) must never return None as filename
assert filename is not None
(fn, extension) = os.path.splitext(filename)
if libconverter.converters.has_converter(extension):
if gl.config.disable_pre_sync_conversion:
@ -372,7 +375,10 @@ class iPodDevice(Device):
self.set_podcast_flags(track)
return True
original_filename = str(episode.local_filename(create=False))
original_filename = episode.local_filename(create=False)
# The file has to exist, if we ought to transfer it, and therefore,
# local_filename(create=False) must never return None as filename
assert original_filename is not None
local_filename = original_filename
if util.calculate_size(original_filename) > self.get_free_space():