From 1afcbbc8379278ad180219e1bdec1d7a19b7ae61 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 16 Sep 2011 10:15:37 +0200 Subject: [PATCH] Fixed bug #851653, added an if statement, and fixed the orphaned variable. Fixes: https://launchpad.net/bugs/851653 --- openlp/plugins/songs/lib/mediaitem.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 381e2611c..7d5e85af5 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -399,8 +399,10 @@ class SongMediaItem(MediaManagerItem): except: log.exception('Could not remove file: %s', audio) try: - os.rmdir(os.path.join(AppLocation.get_section_data_path( - self.plugin.name), 'audio', str(item_id))) + save_path = os.path.join(AppLocation.get_section_data_path( + self.plugin.name), 'audio', str(item_id)) + if os.path.exists(save_path): + os.rmdir(save_path) except OSError: log.exception(u'Could not remove directory: %s', save_path) self.plugin.manager.delete_object(Song, item_id)