mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 14:05:58 +03:00
SocketApi: Properly manage the database connections.
Removed the fishy closeDb() method of SqlQuery again.
This commit is contained in:
parent
f0dc3725e8
commit
26f068bcab
4 changed files with 11 additions and 12 deletions
|
@ -286,11 +286,4 @@ void SqlQuery::reset()
|
|||
SQLITE_DO(sqlite3_reset(_stmt));
|
||||
}
|
||||
|
||||
void SqlQuery::closeDb()
|
||||
{
|
||||
if( _db) {
|
||||
SQLITE_DO(sqlite3_close(_db) );
|
||||
_db = 0;
|
||||
}
|
||||
}
|
||||
} // namespace Mirall
|
||||
|
|
|
@ -57,9 +57,6 @@ public:
|
|||
quint64 int64Value(int index);
|
||||
QByteArray baValue(int index);
|
||||
|
||||
// use only in rare cases, invalidates the internal db object.
|
||||
void closeDb();
|
||||
|
||||
bool isSelect();
|
||||
bool isPragma();
|
||||
bool exec();
|
||||
|
|
|
@ -229,10 +229,16 @@ void SocketApi::slotUnregisterPath( const QString& alias )
|
|||
SqlQuery *h = _dbQueries[f];
|
||||
if( h ) {
|
||||
h->finish();
|
||||
h->closeDb();
|
||||
}
|
||||
_dbQueries.remove(f);
|
||||
}
|
||||
if( _openDbs.contains(f) ) {
|
||||
SqlDatabase *db = _openDbs[f];
|
||||
if( db ) {
|
||||
db->close();
|
||||
}
|
||||
_openDbs.remove(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +399,9 @@ SqlQuery* SocketApi::getSqlQuery( Folder *folder )
|
|||
if( fi.exists() ) {
|
||||
SqlDatabase *db = new SqlDatabase;
|
||||
|
||||
if( db->open(dbFileName) ) {
|
||||
if( db && db->open(dbFileName) ) {
|
||||
_openDbs.insert(folder, db);
|
||||
|
||||
SqlQuery *query = new SqlQuery(*db);
|
||||
rc = query->prepare(sql);
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
QList<SocketType*> _listeners;
|
||||
c_strlist_t *_excludes;
|
||||
QHash<Folder*, SqlQuery*> _dbQueries;
|
||||
QHash<Folder*, SqlDatabase*> _openDbs;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue