Commit f46d09bc authored by fred's avatar fred

misc: don't crash on duplicated tracks with missing files

parent 8e812831
Pipeline #103 failed with stages
......@@ -74,11 +74,17 @@ class Track(models.Model):
).exclude(on_air=False).order_by('-play_timestamp')
def file_path(self):
return self.nonstopfile_set.all().order_by('creation_timestamp').last().get_local_filepath()
nfile = None
for nfile in self.nonstopfile_set.all().order_by('creation_timestamp'):
if os.path.exists(nfile.get_local_filepath()):
return nfile.get_local_filepath()
if nfile:
return nfile.get_local_filepath()
return None
def file_exists(self):
try:
return os.path.exists(self.nonstopfile_set.order_by('creation_timestamp').last().get_local_filepath())
return os.path.exists(self.file_path())
except AttributeError:
return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment