diff options
author | Arno <arno@disconnect.de> | 2016-04-02 12:20:02 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-04-02 12:20:02 +0200 |
commit | 26ba486f27f55251d9ffadcdf18e50e52f3d627f (patch) | |
tree | 9413505f63c388a9bd30c6865ed6164311edf558 | |
parent | 3f5ee806075e9c68862fd6cba2650b969511c916 (diff) | |
download | SheMov-26ba486f27f55251d9ffadcdf18e50e52f3d627f.tar.gz SheMov-26ba486f27f55251d9ffadcdf18e50e52f3d627f.tar.bz2 SheMov-26ba486f27f55251d9ffadcdf18e50e52f3d627f.zip |
Reconnect cloned databases
Try to reconnect cloned databases on error, mainly SmDirWatcher and
ArchiveCollector. ConsistencyCheck doesn't matter, since it's on the
stack. It compiles, but no idea if it actually works...
-rw-r--r-- | archivemodel.cpp | 12 | ||||
-rw-r--r-- | smdirwatcher.cpp | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp index 4b0c720..68b7e4f 100644 --- a/archivemodel.cpp +++ b/archivemodel.cpp @@ -1096,7 +1096,16 @@ void ArchiveCollector::setCancelled(bool cancel){ } void ArchiveCollector::run(){ - mAccessMx.lock(); + QMutexLocker l(&mAccessMx); + // check if db is still connected + // if not, skip this run and leave everything as is + QSqlQuery dummy(mDb); + dummy.prepare("SELECT 1"); + if(!dummy.exec()){ + mDb.close(); + mDb.open(); + return; + } delete mRootItem; mRootItem = new SmTreeItem(mNumFields); switch (mSortOrder){ @@ -1118,7 +1127,6 @@ void ArchiveCollector::run(){ default: return; } - mAccessMx.unlock(); } void ArchiveCollector::populateBySeriesName() { diff --git a/smdirwatcher.cpp b/smdirwatcher.cpp index 3fec952..46ec905 100644 --- a/smdirwatcher.cpp +++ b/smdirwatcher.cpp @@ -98,7 +98,11 @@ int SmDirWatcher::presenceData(QString &md5){ QSqlQuery present1Q(mDb); present1Q.prepare("SELECT COUNT(*) FROM files WHERE cmd5sum = :md5"); present1Q.bindValue(":md5", md5); - present1Q.exec(); + if(!present1Q.exec()){ + mDb.close(); + mDb.open(); + return SmDirModel::InNone; + } while(present1Q.next()){ int c = present1Q.value(0).toInt(); if(c > 0){ |