DatabaseSong: new library merging duplicate code

This commit is contained in:
Max Kellermann
2014-01-15 18:25:58 +01:00
parent e2812f722d
commit 32ec672311
6 changed files with 91 additions and 35 deletions

View File

@@ -22,8 +22,7 @@
#include "PlaylistSave.hxx"
#include "PlaylistInfo.hxx"
#include "PlaylistVector.hxx"
#include "DatabasePlugin.hxx"
#include "DatabaseGlue.hxx"
#include "DatabaseSong.hxx"
#include "DetachedSong.hxx"
#include "Mapper.hxx"
#include "fs/TextFile.hxx"
@@ -405,18 +404,13 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
return spl_append_song(utf8file, DetachedSong(url),
error);
} else {
const Database *db = GetDatabase(error);
if (db == nullptr)
DetachedSong *song = DatabaseDetachSong(url, error);
if (song == nullptr)
return false;
Song *tmp = db->GetSong(url, error);
if (tmp == nullptr)
return false;
const DetachedSong song(*tmp);
db->ReturnSong(tmp);
return spl_append_song(utf8file, song, error);
bool success = spl_append_song(utf8file, *song, error);
delete song;
return success;
}
}