plugin radiocol: fix wrong call of deleteFile

This commit is contained in:
souliane 2013-12-17 11:35:41 +01:00
commit 5b632eca67

View file

@ -131,7 +131,7 @@ class Radiocol(object):
debug(_('No more participants in the radiocol: cleaning data'))
radio_data['queue'] = []
for filename in radio_data['to_delete']:
self.deleteFile(radio_data, filename)
self.deleteFile(filename, radio_data)
radio_data['to_delete'] = {}
queue = radio_data['queue']
if not queue:
@ -150,14 +150,23 @@ class Radiocol(object):
reactor.callLater(length, self.playNext, room_jid, profile)
#we wait more than the song length to delete the file, to manage poorly reactive networks/clients
reactor.callLater(length + 90, self.deleteFile, radio_data, filename) # FIXME: same host trick (see above)
reactor.callLater(length + 90, self.deleteFile, filename, radio_data) # FIXME: same host trick (see above)
def deleteFile(self, radio_data, filename):
try:
file_to_delete = radio_data['to_delete'][filename]
except KeyError:
error(_("INTERNAL ERROR: can't find full path of the song to delete"))
return False
def deleteFile(self, filename, radio_data=None):
"""
Delete a previously uploaded file.
@param filename: filename to delete, or full filepath if radio_data is None
@param radio_data: current game data
@return: True if the file has been deleted
"""
if radio_data:
try:
file_to_delete = radio_data['to_delete'][filename]
except KeyError:
error(_("INTERNAL ERROR: can't find full path of the song to delete"))
return False
else:
file_to_delete = filename
try:
unlink(file_to_delete)
except OSError: