mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-08-03 17:39:27 +02:00
2018-08-16 Fred Gleason <fredg@paravelsystems.com>
* Added table rewriting when converting tables to a different character set in rddbmgr(8).
This commit is contained in:
parent
c7335075f2
commit
110fdf856f
@ -17452,3 +17452,6 @@
|
|||||||
2018-08-16 Fred Gleason <fredg@paravelsystems.com>
|
2018-08-16 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Fixed a rendering error in the 'Edit RDAirPlay dialog in
|
* Fixed a rendering error in the 'Edit RDAirPlay dialog in
|
||||||
rdadmin(1).
|
rdadmin(1).
|
||||||
|
2018-08-16 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added table rewriting when converting tables to a different
|
||||||
|
character set in rddbmgr(8).
|
||||||
|
@ -926,8 +926,8 @@ QString RDCartDialog::StateFile() {
|
|||||||
|
|
||||||
void RDCartDialog::LoadState()
|
void RDCartDialog::LoadState()
|
||||||
{
|
{
|
||||||
QString state_file = StateFile();
|
QString state_file=StateFile();
|
||||||
if (state_file == NULL) {
|
if (state_file.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,8 +945,8 @@ void RDCartDialog::SaveState()
|
|||||||
{
|
{
|
||||||
FILE *f=NULL;
|
FILE *f=NULL;
|
||||||
|
|
||||||
QString state_file = StateFile();
|
QString state_file=StateFile();
|
||||||
if (state_file == NULL) {
|
if (state_file.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,6 +961,14 @@ QString RDHomeDir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDTempDir()
|
||||||
|
{
|
||||||
|
char path[PATH_MAX]="/tmp/rddbmgrXXXXXX";
|
||||||
|
|
||||||
|
return QString(mkdtemp(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RDTempFile()
|
QString RDTempFile()
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -100,6 +100,7 @@ QString RDGetHomeDir(bool *found=0);
|
|||||||
bool RDTimeSynced();
|
bool RDTimeSynced();
|
||||||
QString RDTruncateAfterWord(QString str,int word,bool add_dots=false);
|
QString RDTruncateAfterWord(QString str,int word,bool add_dots=false);
|
||||||
QString RDHomeDir();
|
QString RDHomeDir();
|
||||||
|
QString RDTempDir();
|
||||||
QString RDTempFile();
|
QString RDTempFile();
|
||||||
QString RDTimeZoneName(const QDateTime &datetime);
|
QString RDTimeZoneName(const QDateTime &datetime);
|
||||||
QString RDDowCode(int dow);
|
QString RDDowCode(int dow);
|
||||||
|
@ -26,10 +26,12 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
|
#include <qprocess.h>
|
||||||
|
|
||||||
#include <dbversion.h>
|
#include <dbversion.h>
|
||||||
#include <rdcart.h>
|
#include <rdcart.h>
|
||||||
#include <rdclock.h>
|
#include <rdclock.h>
|
||||||
|
#include <rdconf.h>
|
||||||
#include <rdcut.h>
|
#include <rdcut.h>
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rdescape_string.h>
|
#include <rdescape_string.h>
|
||||||
@ -39,7 +41,7 @@
|
|||||||
|
|
||||||
#include "rddbmgr.h"
|
#include "rddbmgr.h"
|
||||||
|
|
||||||
bool MainObject::Check(QString *err_msg) const
|
bool MainObject::Check(QString *err_msg)
|
||||||
{
|
{
|
||||||
if(GetCurrentSchema()!=RD_VERSION_DATABASE) {
|
if(GetCurrentSchema()!=RD_VERSION_DATABASE) {
|
||||||
*err_msg="unsupported schema for checking";
|
*err_msg="unsupported schema for checking";
|
||||||
@ -124,7 +126,7 @@ bool MainObject::Check(QString *err_msg) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::CheckTableAttributes() const
|
void MainObject::CheckTableAttributes()
|
||||||
{
|
{
|
||||||
QString sql;
|
QString sql;
|
||||||
RDSqlQuery *q;
|
RDSqlQuery *q;
|
||||||
@ -163,10 +165,8 @@ void MainObject::CheckTableAttributes() const
|
|||||||
(const char *)db_mysql_collation.toUtf8());
|
(const char *)db_mysql_collation.toUtf8());
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
if(UserResponse()) {
|
if(UserResponse()) {
|
||||||
sql=QString("alter table `")+q->value(0).toString()+"` "+
|
RewriteTable(q->value(0).toString(),charset,db_mysql_charset,
|
||||||
"character set "+db_mysql_charset+" "+
|
db_mysql_collation);
|
||||||
"collate "+db_mysql_collation;
|
|
||||||
RDSqlQuery::apply(sql);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,6 +204,75 @@ void MainObject::CheckTableAttributes() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainObject::RewriteTable(const QString &tblname,const QString &old_charset,
|
||||||
|
const QString &new_charset,
|
||||||
|
const QString &new_collation)
|
||||||
|
{
|
||||||
|
QProcess *proc=NULL;
|
||||||
|
QStringList args;
|
||||||
|
QString tempdir=RDTempDir();
|
||||||
|
if(tempdir.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString filename=tempdir+"/table.sql";
|
||||||
|
QString out_filename=tempdir+"/table-out.sql";
|
||||||
|
printf("using: %s\n",(const char *)tempdir.toUtf8());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dump Table
|
||||||
|
//
|
||||||
|
args.clear();
|
||||||
|
args.push_back("--opt");
|
||||||
|
args.push_back("-h");
|
||||||
|
args.push_back(db_mysql_hostname);
|
||||||
|
args.push_back("-u");
|
||||||
|
args.push_back(db_mysql_loginname);
|
||||||
|
args.push_back("-p"+db_mysql_password);
|
||||||
|
args.push_back(db_mysql_database);
|
||||||
|
args.push_back(tblname);
|
||||||
|
proc=new QProcess(this);
|
||||||
|
proc->setStandardOutputFile(filename);
|
||||||
|
proc->start("mysqldump",args);
|
||||||
|
proc->waitForFinished(-1);
|
||||||
|
delete proc;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Modify Dump
|
||||||
|
//
|
||||||
|
args.clear();
|
||||||
|
args.push_back("s/"+old_charset+"/"+new_charset+"/g");
|
||||||
|
args.push_back(filename);
|
||||||
|
proc=new QProcess(this);
|
||||||
|
proc->setStandardOutputFile(out_filename);
|
||||||
|
proc->start("sed",args);
|
||||||
|
proc->waitForFinished(-1);
|
||||||
|
delete proc;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Push Back Modified Table
|
||||||
|
//
|
||||||
|
args.clear();
|
||||||
|
args.push_back("-h");
|
||||||
|
args.push_back(db_mysql_hostname);
|
||||||
|
args.push_back("-u");
|
||||||
|
args.push_back(db_mysql_loginname);
|
||||||
|
args.push_back("-p"+db_mysql_password);
|
||||||
|
args.push_back(db_mysql_database);
|
||||||
|
proc=new QProcess(this);
|
||||||
|
proc->setStandardInputFile(out_filename);
|
||||||
|
proc->start("mysql",args);
|
||||||
|
proc->waitForFinished(-1);
|
||||||
|
delete proc;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clean Up
|
||||||
|
//
|
||||||
|
unlink(filename.toUtf8());
|
||||||
|
unlink(out_filename.toUtf8());
|
||||||
|
rmdir(tempdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::RelinkAudio(const QString &srcdir) const
|
void MainObject::RelinkAudio(const QString &srcdir) const
|
||||||
{
|
{
|
||||||
QString sql;
|
QString sql;
|
||||||
|
@ -40,8 +40,11 @@ class MainObject : public QObject
|
|||||||
//
|
//
|
||||||
// check.cpp
|
// check.cpp
|
||||||
//
|
//
|
||||||
bool Check(QString *err_msg) const;
|
bool Check(QString *err_msg);
|
||||||
void CheckTableAttributes() const;
|
void CheckTableAttributes();
|
||||||
|
void RewriteTable(const QString &tblname,const QString &old_charset,
|
||||||
|
const QString &new_charset,
|
||||||
|
const QString &new_collation);
|
||||||
void RelinkAudio(const QString &srcdir) const;
|
void RelinkAudio(const QString &srcdir) const;
|
||||||
void CheckOrphanedTracks() const;
|
void CheckOrphanedTracks() const;
|
||||||
void CheckCutCounts() const;
|
void CheckCutCounts() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user