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