Ticket #5286: mythtv-5286-no_backup_for_new_database-20080615.patch

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

Updates mythtv-5286-no_backup_for_new_database.patch for changes in [17479]

  • libs/libmyth/dbutil.h

    old new  
    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

    old new  
    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 */
     
    169182        return true;
    170183    }
    171184
     185    filename = "";
     186    if (IsNewDatabase())
     187    {
     188        VERBOSE(VB_IMPORTANT, "New database detected.  Skipping backup.");
     189        return true;
     190    }
     191
    172192    bool result = false;
    173193    MSqlQuery query(MSqlQuery::InitCon());
    174194
  • libs/libmythtv/dbcheck.cpp

    old new  
    556556
    557557    QString backupResult = "";
    558558#ifndef USING_MINGW
    559     if (dbver != "0")
    560559        dbutil.BackupDB(backupResult);
    561560#endif
    562561