mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
safer approach for detecting duplicate sync runs
This commit is contained in:
parent
3cae8e7124
commit
acdb624713
@ -50,6 +50,7 @@ QNetworkProxy CSyncThread::_proxy;
|
||||
QString CSyncThread::_csyncConfigDir; // to be able to remove the lock file.
|
||||
|
||||
QMutex CSyncThread::_mutex;
|
||||
QMutex CSyncThread::_syncMutex;
|
||||
|
||||
void csyncLogCatcher(CSYNC *ctx,
|
||||
int verbosity,
|
||||
@ -303,6 +304,7 @@ struct CSyncRunScopeHelper {
|
||||
|
||||
qDebug() << "CSync run took " << t.elapsed() << " Milliseconds";
|
||||
emit(parent->finished());
|
||||
parent->_syncMutex.unlock();
|
||||
}
|
||||
CSYNC *ctx;
|
||||
QTime t;
|
||||
@ -326,6 +328,11 @@ void CSyncThread::handleSyncError(CSYNC *ctx, const char *state) {
|
||||
|
||||
void CSyncThread::startSync()
|
||||
{
|
||||
if (!_syncMutex.tryLock()) {
|
||||
qDebug() << Q_FUNC_INFO << "WARNING: Another sync seems to be running. Not starting a new one.";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Sync started";
|
||||
|
||||
qDebug() << "starting to sync " << qApp->thread() << QThread::currentThread();
|
||||
|
||||
@ -83,6 +83,7 @@ private:
|
||||
);
|
||||
|
||||
static QMutex _mutex;
|
||||
static QMutex _syncMutex;
|
||||
static QString _user;
|
||||
static QString _passwd;
|
||||
static QNetworkProxy _proxy;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user