mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-26 15:23:50 +01:00
2017-03-29 Fred Gleason <fredg@paravelsystems.com>
* Added a 'CUTS.SHA1_HASH' field to the database. * Incremented the database version to 261. * Added a 'Sha1' column to the Cut List in 'rdlibrary/audio_cart.cpp'. * Added 'RDCut::sha1Hash()' and 'RDCut::setSha1Hash()' methods in 'lib/rdcut.cpp' and 'lib/rdcut.h'. * Added a '--rehash=' directive to rddbcheck(8). * Added a 'Rehash' Web API call. * Added an 'RDRehash' class in 'lib/rdrehash.cpp' and 'lib/rdrehash.h'.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <rd.h>
|
||||
#include <rddbcheck.h>
|
||||
#include <rdcart.h>
|
||||
#include <rdhash.h>
|
||||
#include <rdlog.h>
|
||||
#include <rdclock.h>
|
||||
#include <rdcreate_log.h>
|
||||
@@ -81,6 +82,9 @@ MainObject::MainObject(QObject *parent)
|
||||
if(cmd->key(i)=="--dump-cuts-dir") {
|
||||
dump_cuts_dir=cmd->value(i);
|
||||
}
|
||||
if(cmd->key(i)=="--rehash") {
|
||||
rehash=cmd->value(i);
|
||||
}
|
||||
}
|
||||
if(check_yes&&check_no) {
|
||||
fprintf(stderr,"rddbcheck: '--yes' and '--no' are mutually exclusive\n");
|
||||
@@ -171,6 +175,14 @@ MainObject::MainObject(QObject *parent)
|
||||
delete q;
|
||||
}
|
||||
|
||||
//
|
||||
// Rehash
|
||||
//
|
||||
if(!rehash.isEmpty()) {
|
||||
Rehash(rehash);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Orphaned Voice Tracks
|
||||
//
|
||||
@@ -685,6 +697,95 @@ void MainObject::ValidateAudioLengths()
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Rehash(const QString &arg)
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
unsigned cartnum;
|
||||
bool ok=false;
|
||||
|
||||
if(arg.lower()=="all") {
|
||||
sql=QString("select NUMBER from CART where ")+
|
||||
QString().sprintf("TYPE=%d ",RDCart::Audio)+
|
||||
"order by NUMBER";
|
||||
q=new QSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
RehashCart(q->value(0).toUInt());
|
||||
}
|
||||
delete q;
|
||||
return;
|
||||
}
|
||||
cartnum=arg.toUInt(&ok);
|
||||
if(ok&&(cartnum>0)&&(cartnum<=RD_MAX_CART_NUMBER)) {
|
||||
RehashCart(cartnum);
|
||||
return;
|
||||
}
|
||||
RDCut *cut=new RDCut(arg);
|
||||
if(cut->exists()) {
|
||||
RehashCut(arg);
|
||||
}
|
||||
delete cut;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::RehashCart(unsigned cartnum)
|
||||
{
|
||||
RDCart *cart=new RDCart(cartnum);
|
||||
if(cart->exists()) {
|
||||
if(cart->type()==RDCart::Audio) {
|
||||
QString sql=QString("select CUT_NAME from CUTS where ")+
|
||||
QString().sprintf("CART_NUMBER=%u ",cartnum)+
|
||||
"order by CUT_NAME";
|
||||
QSqlQuery *q=new QSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
RehashCut(q->value(0).toString());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf(" Cart %06u does not exist.\n",cartnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::RehashCut(const QString &cutnum)
|
||||
{
|
||||
QString hash=RDSha1Hash(RDCut::pathName(cutnum),true);
|
||||
if(hash.isEmpty()) {
|
||||
printf(" Unable to generate hash for \"%s\"\n",
|
||||
(const char *)RDCut::pathName(cutnum));
|
||||
}
|
||||
else {
|
||||
RDCut *cut=new RDCut(cutnum);
|
||||
if(cut->exists()) {
|
||||
if(cut->sha1Hash().isEmpty()) {
|
||||
cut->setSha1Hash(hash);
|
||||
}
|
||||
else {
|
||||
if(cut->sha1Hash()!=hash) {
|
||||
RDCart *cart=new RDCart(RDCut::cartNumber(cutnum));
|
||||
printf(" Cut %d [%s] in cart %06u [%s] has inconsistent SHA1 hash. Correct? (y/N) ",
|
||||
cut->cutNumber(),
|
||||
(const char *)cut->description(),
|
||||
cart->number(),
|
||||
(const char *)cart->title());
|
||||
fflush(NULL);
|
||||
if(UserResponse()) {
|
||||
cut->setSha1Hash(hash);
|
||||
}
|
||||
delete cart;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf(" Cut \"%s\" does not exist.\n",(const char *)cutnum);
|
||||
}
|
||||
delete cut;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::SetCutLength(const QString &cutname,int len)
|
||||
{
|
||||
QString sql;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <rdcmd_switch.cpp>
|
||||
#include <rdstation.h>
|
||||
|
||||
#define RDDBCHECK_USAGE "[options]\n\nCheck the Rivendell database and audio store for consistency\nand correctness.\n\n--yes\n Answer all questions with 'yes'\n\n--no\n Answer all questions with 'no'\n\n--user=<username>\n Connect using the Rivendell user <username> (default is \"user\").\n\n--orphan-group=<group-name>\n Move carts with missing/invalid GROUP information to the <group-name>\n group.\n\n--dump-cuts-dir=<dir-name>\n Move orphaned cut audio to the <dir-name> directory.\n"
|
||||
#define RDDBCHECK_USAGE "[options]\n\nCheck the Rivendell database and audio store for consistency\nand correctness.\n\n--yes\n Answer all questions with 'yes'\n\n--no\n Answer all questions with 'no'\n\n--user=<username>\n Connect using the Rivendell user <username> (default is \"user\").\n\n--orphan-group=<group-name>\n Move carts with missing/invalid GROUP information to the <group-name>\n group.\n\n--dump-cuts-dir=<dir-name>\n Move orphaned cut audio to the <dir-name> directory.\n\n--rehash=<cartnum>/ALL"
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
@@ -54,6 +54,9 @@ class MainObject : public QObject
|
||||
void CheckOrphanedCuts();
|
||||
void CheckOrphanedAudio();
|
||||
void ValidateAudioLengths();
|
||||
void Rehash(const QString &arg);
|
||||
void RehashCart(unsigned cartnum);
|
||||
void RehashCut(const QString &cutnum);
|
||||
void SetCutLength(const QString &cutname,int len);
|
||||
void CleanTables(const QString &ext,QSqlQuery *table_q,QSqlQuery *name_q);
|
||||
void CleanTables(const QString &ext,QSqlQuery *table_q);
|
||||
@@ -63,6 +66,7 @@ class MainObject : public QObject
|
||||
bool check_no;
|
||||
QString orphan_group_name;
|
||||
QString dump_cuts_dir;
|
||||
QString rehash;
|
||||
RDStation *check_station;
|
||||
RDUser *check_user;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user