mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-07 07:57:44 +02:00
2022-12-21 Fred Gleason <fredg@paravelsystems.com>
* Added a test for duplicate log line IDs to rddbmgr(8). * Added a '--check-log-line-ids' switch to rddbmgr(8). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
677f856fbe
commit
61b9a08f2a
@ -23835,3 +23835,6 @@
|
||||
when posting a new item.
|
||||
2022-12-19 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Incremented the package version to 4.0.0rc0int10.
|
||||
2022-12-21 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a test for duplicate log line IDs to rddbmgr(8).
|
||||
* Added a '--check-log-line-ids' switch to rddbmgr(8).
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Routines for --check for rddbmgr(8)
|
||||
//
|
||||
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2018-2022 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -153,6 +153,23 @@ bool MainObject::Check(QString *err_msg)
|
||||
printf("done.\n\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Log Line IDs
|
||||
//
|
||||
if(db_check_all||db_check_log_line_ids) {
|
||||
printf("Checking log line IDs...\n");
|
||||
QString sql=QString("select ")+
|
||||
"`NAME` "+ // 00
|
||||
"from `LOGS` "+
|
||||
"order by `NAME`";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
CheckLogLineIds(q->value(0).toString());
|
||||
}
|
||||
delete q;
|
||||
printf("done.\n\n");
|
||||
}
|
||||
|
||||
*err_msg="ok";
|
||||
return true;
|
||||
}
|
||||
@ -853,6 +870,65 @@ void MainObject::CheckOrphanedAudio() const
|
||||
}
|
||||
|
||||
|
||||
void MainObject::CheckLogLineIds(const QString &logname) const
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q=NULL;
|
||||
int prev_line_id=-1;
|
||||
|
||||
sql=QString("select ")+
|
||||
"`ID`,"+ // 00
|
||||
"`COUNT`,"+ // 01
|
||||
"`LINE_ID` "+ // 02
|
||||
"from `LOG_LINES` where "+
|
||||
"`LOG_NAME`='"+RDEscapeString(logname)+"' "+
|
||||
"order by `LINE_ID`";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
if(q->value(2).toInt()==prev_line_id) {
|
||||
printf(" Duplicate line ID found in log \"%s\" at line %d\n",
|
||||
logname.toUtf8().constData(),q->value(1).toInt());
|
||||
printf(" Repair it (y/N)?");
|
||||
if(UserResponse()) {
|
||||
//
|
||||
// Calculate next unused line ID
|
||||
//
|
||||
int next_line_id=1;
|
||||
sql=QString("select ")+
|
||||
"`LINE_ID` "+
|
||||
"from `LOG_LINES` where "+
|
||||
"`LOG_NAME`='"+RDEscapeString(logname)+"' "+
|
||||
"order by `LINE_ID` desc";
|
||||
RDSqlQuery *q1=new RDSqlQuery(sql);
|
||||
if(q1->first()) {
|
||||
next_line_id=q1->value(0).toInt()+1;
|
||||
}
|
||||
delete q1;
|
||||
|
||||
//
|
||||
// Rewrite line ID
|
||||
//
|
||||
sql=QString("update `LOG_LINES` set ")+
|
||||
QString::asprintf("`LINE_ID`=%d ",next_line_id)+
|
||||
"where "+
|
||||
QString::asprintf("`ID`=%d",q->value(0).toInt());
|
||||
RDSqlQuery::apply(sql);
|
||||
next_line_id++;
|
||||
|
||||
sql=QString("update `LOGS` set ")+
|
||||
QString::asprintf("`NEXT_ID`=%d ",next_line_id)+
|
||||
"where "+
|
||||
"`NAME`='"+RDEscapeString(logname)+"'";
|
||||
RDSqlQuery::apply(sql);
|
||||
next_line_id++;
|
||||
}
|
||||
}
|
||||
prev_line_id=q->value(2).toInt();
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ValidateAudioLengths() const
|
||||
{
|
||||
QString sql;
|
||||
|
@ -59,6 +59,7 @@ MainObject::MainObject(QObject *parent)
|
||||
db_check_orphaned_cuts=false;
|
||||
db_check_orphaned_tracks=false;
|
||||
db_check_strings=false;
|
||||
db_check_log_line_ids=false;
|
||||
|
||||
//
|
||||
// Check that we're 'root'
|
||||
@ -240,6 +241,11 @@ MainObject::MainObject(QObject *parent)
|
||||
db_check_strings=true;
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--check-log-line-ids") {
|
||||
db_check_all=false;
|
||||
db_check_log_line_ids=true;
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
|
||||
if(!cmd->processed(i)) {
|
||||
fprintf(stderr,"rddbmgr: unrecognized option \"%s\"\n",
|
||||
|
@ -63,6 +63,7 @@ class MainObject : public QObject
|
||||
void CheckOrphanedCarts() const;
|
||||
void CheckOrphanedCuts() const;
|
||||
void CheckOrphanedAudio() const;
|
||||
void CheckLogLineIds(const QString &logname) const;
|
||||
void ValidateAudioLengths() const;
|
||||
void Rehash(const QString &arg) const;
|
||||
void RehashCart(unsigned cartnum) const;
|
||||
@ -155,6 +156,7 @@ class MainObject : public QObject
|
||||
bool db_check_orphaned_carts;
|
||||
bool db_check_orphaned_cuts;
|
||||
bool db_check_strings;
|
||||
bool db_check_log_line_ids;
|
||||
QString db_orphan_group_name;
|
||||
QString db_dump_cuts_dir;
|
||||
QString db_rehash;
|
||||
|
Loading…
x
Reference in New Issue
Block a user