Merged revisions 834988 via svnmerge from

svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise4/kdepim

........
  r834988 | tilladam | 2008-07-19 21:39:51 +0200 (Sat, 19 Jul 2008) | 1 line
  
  Don't silently skip writing the index when deleting the existing db file fails, on Windows. Instead, drop the messages table, since the removal of the file doesn't work due to it still being referenced.\nkolab/issue2705, issue2795, issue2697
........

svn path=/trunk/KDE/kdepim/; revision=836052
wilder-work
Thomas McGuire 18 years ago
parent 274be48f5d
commit d480c69a02
  1. 20
      kmfolderindex_sqlite.cpp

@ -140,27 +140,29 @@ int KMFolderIndex::writeIndex( bool createEmptyIndex )
return 0;
}
QString indexName = QDir::toNativeSeparators( indexLocation() );
if ( mIndexDb ) {
sqlite3_close( mIndexDb );
mIndexDb = 0;
}
{
QFile indexFile( indexName );
if ( indexFile.exists() && !indexFile.remove() )
const QString indexName = QDir::toNativeSeparators( indexLocation() );
const bool existingDatabase = QFile::exists( indexName );
const bool ok = openDatabase( SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE );
if ( !ok ) {
kWarning() << "Opening the db " << indexName << " failed!";
return 1;
}
bool ok = openDatabase( SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE );
if ( !ok )
return 1;
// create data structures if not available
// - index version
QString sql( QLatin1String("PRAGMA user_version = ") + QString::number( INDEX_VERSION ) );
if ( !executeQuery( mIndexDb, sql ) )
return 1;
// - drop the 'messages' table, if it exists
if ( existingDatabase && !executeQuery( mIndexDb, "DROP TABLE messages" ) )
return 1;
// - 'messages' table
if ( !executeQuery( mIndexDb, "CREATE TABLE messages( id INTEGER PRIMARY KEY AUTOINCREMENT, data BLOB )" ) )
return 1;
@ -359,7 +361,7 @@ bool KMFolderIndex::readIndexHeader(int *gv)
if ( ok )
indexVersion = str.toInt(&ok);
if ( !ok ) {
qWarning() << "index file has invalid header '" << str << "'";
kWarning() << "index file has invalid header '" << str << "'";
return false;
}

Loading…
Cancel
Save