Ticket #5286: mythtv-5286-no_backup_for_new_database.patch

File mythtv-5286-no_backup_for_new_database.patch, 1.8 KB (added by sphery <mtdean@…>, 17 years ago)

Adds DBUtil::IsNewDatabase?() and moves check for whether to do a backup to DBUtil::DoBackup?()

  • libs/libmyth/dbutil.h

     
    3030    bool BackupDB(QString &filename);
    3131
    3232    static QMap<QString,bool> GetTableMap(void);
     33    static bool IsNewDatabase(void);
    3334    static bool IsBackupInProgress(void);
    3435
    3536    static const int kUnknownVersionNumber;
  • libs/libmyth/dbutil.cpp

     
    7070    return result;
    7171}
    7272
    73 /** \fn DBUtil::BackupInProgress(void)
     73/** \fn DBUtil::IsNewDatabase(void)
     74 *  \brief Returns true for a new (empty) database.
     75 */
     76bool DBUtil::IsNewDatabase(void)
     77{
     78    const QStringList tables = GetTables();
     79    const int size = tables.size();
     80    // Usually there will be a single table called schemalock, but check for
     81    // no tables, also, just in case.
     82    return (((size == 1) && (tables.at(0) == "schemalock")) ||
     83            (size == 0));
     84}
     85
     86/** \fn DBUtil::IsBackupInProgress(void)
    7487 *  \brief Test to see if a DB backup is in progress
    7588 *
    7689 */
     
    162175 */
    163176bool DBUtil::BackupDB(QString &filename)
    164177{
     178    filename = "";
     179    if (IsNewDatabase())
     180    {
     181        VERBOSE(VB_IMPORTANT, "New database detected.  Skipping backup.");
     182        return true;
     183    }
     184
    165185    bool result = false;
    166186    MSqlQuery query(MSqlQuery::InitCon());
    167187
  • libs/libmythtv/dbcheck.cpp

     
    555555
    556556    QString backupResult = "";
    557557#ifndef USING_MINGW
    558     if (dbver != "0")
    559558        dbutil.BackupDB(backupResult);
    560559#endif
    561560