Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-855342 into 
lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #855342 in OpenLP: "File not found error when saving a service with audio 
files"
  https://bugs.launchpad.net/openlp/+bug/855342

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-855342/+merge/76482

Fixed bug #855342 where saving an already-saved service file with an audio file 
in it caused an exception.
-- 
https://code.launchpad.net/~raoul-snyman/openlp/bug-855342/+merge/76482
Your team OpenLP Core is requested to review the proposed merge of 
lp:~raoul-snyman/openlp/bug-855342 into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-08-31 07:49:57 +0000
+++ openlp/core/ui/servicemanager.py	2011-09-21 21:39:27 +0000
@@ -554,6 +554,18 @@
             for path_from in write_list:
                 zip.write(path_from, path_from.encode(u'utf-8'))
             for path_from, path_to in audio_files:
+                if path_from == path_to:
+                    # If this file has already been saved, let's use set the
+                    # from path to the real location of the files
+                    path_from = os.path.join(self.servicePath, path_from)
+                else:
+                    # If this file has not yet been saved, let's copy the file
+                    # to the service manager path
+                    save_file = os.path.join(self.servicePath, path_to)
+                    save_path = os.path.split(save_file)[0]
+                    if not os.path.exists(save_path):
+                        os.makedirs(save_path)
+                    shutil.copy(path_from, save_file)
                 zip.write(path_from, path_to.encode(u'utf-8'))
         except IOError:
             log.exception(u'Failed to save service to disk')

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to