# HG changeset patch # User souliane # Date 1387276541 -3600 # Node ID d0e809014ea28e35c3383e2eaf40b908127bc8a0 # Parent ab851b46009c95c605ac0e8b74c8e3d6c7f77bd5 plugin radiocol: fix wrong call of deleteFile diff -r ab851b46009c -r d0e809014ea2 src/plugins/plugin_misc_radiocol.py --- a/src/plugins/plugin_misc_radiocol.py Tue Dec 24 15:43:52 2013 +0100 +++ b/src/plugins/plugin_misc_radiocol.py Tue Dec 17 11:35:41 2013 +0100 @@ -131,7 +131,7 @@ 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 @@ 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: