forked from openlp/openlp
When cloning a song copy the mediafiles as well. Fixes bug 1309998
Fixes: https://launchpad.net/bugs/1309998
This commit is contained in:
parent
be12ce54bb
commit
402e91f688
@ -395,6 +395,18 @@ class SongMediaItem(MediaManagerItem):
|
||||
new_song = self.open_lyrics.xml_to_song(song_xml)
|
||||
new_song.title = '%s <%s>' % \
|
||||
(new_song.title, translate('SongsPlugin.MediaItem', 'copy', 'For song cloning'))
|
||||
# Copy audio files from the old to the new song
|
||||
if len(old_song.media_files) > 0:
|
||||
save_path = os.path.join(AppLocation.get_section_data_path(self.plugin.name), 'audio', str(new_song.id))
|
||||
check_directory_exists(save_path)
|
||||
for media_file in old_song.media_files:
|
||||
new_media_file_name = os.path.join(save_path, os.path.basename(media_file.file_name))
|
||||
shutil.copyfile(media_file.file_name, new_media_file_name)
|
||||
new_media_file = MediaFile()
|
||||
new_media_file.file_name = new_media_file_name
|
||||
new_media_file.type = media_file.type
|
||||
new_media_file.weight = media_file.weight
|
||||
new_song.media_files.append(new_media_file)
|
||||
self.plugin.manager.save_object(new_song)
|
||||
self.on_song_list_load()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user