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:
parent
343414c52d
commit
f6ab3a9044
@ -488,6 +488,20 @@ void Database::AttachDatabase(const QString& database_name,
|
|||||||
attached_databases_[database_name] = database;
|
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) {
|
void Database::DetachDatabase(const QString& database_name) {
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,9 @@ class Database : public QObject {
|
|||||||
int current_schema_version() const { return kSchemaVersion; }
|
int current_schema_version() const { return kSchemaVersion; }
|
||||||
|
|
||||||
void AttachDatabase(const QString& database_name, const AttachedDatabase& database);
|
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);
|
void DetachDatabase(const QString& database_name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -721,12 +721,12 @@ void OutgoingDataCreator::SendLibrary(RemoteClient *client) {
|
|||||||
|
|
||||||
// Attach this file to the database
|
// Attach this file to the database
|
||||||
Database::AttachedDatabase adb(temp_file_name, "", true);
|
Database::AttachedDatabase adb(temp_file_name, "", true);
|
||||||
app_->database()->AttachDatabase("songs_export", adb);
|
|
||||||
QSqlDatabase db(app_->database()->Connect());
|
QSqlDatabase db(app_->database()->Connect());
|
||||||
|
|
||||||
|
app_->database()->AttachDatabaseOnDbConnection("songs_export", adb, db);
|
||||||
|
|
||||||
// Copy the content of the song table to this temporary database
|
// Copy the content of the song table to this temporary database
|
||||||
QSqlQuery q(QString("create table songs_export.songs as SELECT * FROM songs;"), db);
|
QSqlQuery q(QString("create table songs_export.songs as SELECT * FROM songs;"), db);
|
||||||
q.exec();
|
|
||||||
|
|
||||||
if (app_->database()->CheckErrors(q)) return;
|
if (app_->database()->CheckErrors(q)) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user