1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 20:34:39 +01:00

Fix library download in network remote.

This commit is contained in:
Andreas 2013-10-25 20:31:56 +02:00
parent 343414c52d
commit f6ab3a9044
3 changed files with 19 additions and 2 deletions

View File

@ -488,6 +488,20 @@ void Database::AttachDatabase(const QString& database_name,
attached_databases_[database_name] = database;
}
void Database::AttachDatabaseOnDbConnection(const QString &database_name,
const AttachedDatabase &database,
QSqlDatabase& db) {
AttachDatabase(database_name, database);
// Attach the db
QSqlQuery q("ATTACH DATABASE :filename AS :alias", db);
q.bindValue(":filename", database.filename_);
q.bindValue(":alias", database_name);
if (!q.exec()) {
qFatal("Couldn't attach external database '%s'", database_name.toAscii().constData());
}
}
void Database::DetachDatabase(const QString& database_name) {
QMutexLocker l(&mutex_);
{

View File

@ -74,6 +74,9 @@ class Database : public QObject {
int current_schema_version() const { return kSchemaVersion; }
void AttachDatabase(const QString& database_name, const AttachedDatabase& database);
void AttachDatabaseOnDbConnection(const QString& database_name,
const AttachedDatabase& database,
QSqlDatabase& db);
void DetachDatabase(const QString& database_name);
signals:

View File

@ -721,12 +721,12 @@ void OutgoingDataCreator::SendLibrary(RemoteClient *client) {
// Attach this file to the database
Database::AttachedDatabase adb(temp_file_name, "", true);
app_->database()->AttachDatabase("songs_export", adb);
QSqlDatabase db(app_->database()->Connect());
app_->database()->AttachDatabaseOnDbConnection("songs_export", adb, db);
// Copy the content of the song table to this temporary database
QSqlQuery q(QString("create table songs_export.songs as SELECT * FROM songs;"), db);
q.exec();
if (app_->database()->CheckErrors(q)) return;