mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Wipe the csync statedb after a sync definition is removed.
This commit is contained in:
parent
8b38131b4b
commit
06b3a50e84
7 changed files with 67 additions and 4 deletions
|
@ -137,6 +137,7 @@ void CSyncThread::run()
|
||||||
wStats->seenFiles = 0;
|
wStats->seenFiles = 0;
|
||||||
wStats->conflicts = 0;
|
wStats->conflicts = 0;
|
||||||
wStats->error = 0;
|
wStats->error = 0;
|
||||||
|
const char *statedb = 0;
|
||||||
|
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
if( csync_create(&csync,
|
if( csync_create(&csync,
|
||||||
|
@ -214,6 +215,17 @@ void CSyncThread::run()
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After csync_init the statedb file name can be emitted
|
||||||
|
statedb = csync_get_statedb_file( csync );
|
||||||
|
if( statedb ) {
|
||||||
|
QString stateDbFile = QString::fromUtf8(statedb);
|
||||||
|
free((void*)statedb);
|
||||||
|
|
||||||
|
emit csyncStateDbFile( stateDbFile );
|
||||||
|
} else {
|
||||||
|
qDebug() << "WRN: Unable to get csync statedb file name";
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "############################################################### >>";
|
qDebug() << "############################################################### >>";
|
||||||
if( csync_update(csync) < 0 ) {
|
if( csync_update(csync) < 0 ) {
|
||||||
emit csyncError(tr("CSync Update failed."));
|
emit csyncError(tr("CSync Update failed."));
|
||||||
|
@ -240,7 +252,6 @@ void CSyncThread::run()
|
||||||
emit csyncError(tr("Local filesystem problems. Better disable Syncing and check."));
|
emit csyncError(tr("Local filesystem problems. Better disable Syncing and check."));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
qDebug() << " ..... Local walk finished: " << walkTime.elapsed();
|
|
||||||
|
|
||||||
// emit the treewalk results. Do not touch the wStats after this.
|
// emit the treewalk results. Do not touch the wStats after this.
|
||||||
emit treeWalkResult(wStats);
|
emit treeWalkResult(wStats);
|
||||||
|
@ -248,6 +259,7 @@ void CSyncThread::run()
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
if( _localCheckOnly ) {
|
if( _localCheckOnly ) {
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
|
qDebug() << " ..... Local only walk finished: " << walkTime.elapsed();
|
||||||
// we have to go out here as its local check only.
|
// we have to go out here as its local check only.
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -70,6 +70,8 @@ signals:
|
||||||
void treeWalkResult(WalkStats*);
|
void treeWalkResult(WalkStats*);
|
||||||
void csyncError( const QString& );
|
void csyncError( const QString& );
|
||||||
|
|
||||||
|
void csyncStateDbFile( const QString& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int getauth(const char *prompt,
|
static int getauth(const char *prompt,
|
||||||
char *buf,
|
char *buf,
|
||||||
|
|
|
@ -262,5 +262,10 @@ QString Folder::backend() const
|
||||||
return _backend;
|
return _backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Folder::wipe()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Mirall
|
} // namespace Mirall
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,11 @@ public:
|
||||||
*/
|
*/
|
||||||
QString backend() const;
|
QString backend() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called if the sync folder definition is removed. Do cleanups here.
|
||||||
|
*/
|
||||||
|
virtual void wipe();
|
||||||
|
|
||||||
QIcon icon( int size ) const;
|
QIcon icon( int size ) const;
|
||||||
QTimer *_pollTimer;
|
QTimer *_pollTimer;
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ void FolderMan::removeFolder( const QString& alias )
|
||||||
if( _folderMap.contains( alias )) {
|
if( _folderMap.contains( alias )) {
|
||||||
qDebug() << "Removing " << alias;
|
qDebug() << "Removing " << alias;
|
||||||
Folder *f = _folderMap.take( alias );
|
Folder *f = _folderMap.take( alias );
|
||||||
|
f->wipe();
|
||||||
f->deleteLater();
|
f->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "!! Can not remove " << alias << ", not in folderMap.";
|
qDebug() << "!! Can not remove " << alias << ", not in folderMap.";
|
||||||
|
|
|
@ -68,6 +68,7 @@ ownCloudFolder::ownCloudFolder(const QString &alias,
|
||||||
|
|
||||||
ownCloudFolder::~ownCloudFolder()
|
ownCloudFolder::~ownCloudFolder()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_INOTIFY
|
#ifndef USE_INOTIFY
|
||||||
|
@ -144,6 +145,7 @@ void ownCloudFolder::startSync(const QStringList &pathList)
|
||||||
QObject::connect(_csync, SIGNAL(finished()), SLOT(slotCSyncFinished()));
|
QObject::connect(_csync, SIGNAL(finished()), SLOT(slotCSyncFinished()));
|
||||||
QObject::connect(_csync, SIGNAL(terminated()), SLOT(slotCSyncTerminated()));
|
QObject::connect(_csync, SIGNAL(terminated()), SLOT(slotCSyncTerminated()));
|
||||||
connect(_csync, SIGNAL(csyncError(const QString)), SLOT(slotCSyncError(const QString)));
|
connect(_csync, SIGNAL(csyncError(const QString)), SLOT(slotCSyncError(const QString)));
|
||||||
|
connect(_csync, SIGNAL(csyncStateDbFile(QString)), SLOT(slotCsyncStateDbFile(QString)));
|
||||||
|
|
||||||
connect( _csync, SIGNAL(treeWalkResult(WalkStats*)),
|
connect( _csync, SIGNAL(treeWalkResult(WalkStats*)),
|
||||||
this, SLOT(slotThreadTreeWalkResult(WalkStats*)));
|
this, SLOT(slotThreadTreeWalkResult(WalkStats*)));
|
||||||
|
@ -200,6 +202,12 @@ void ownCloudFolder::slotCSyncError(const QString& err)
|
||||||
_csyncError = true;
|
_csyncError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ownCloudFolder::slotCsyncStateDbFile( const QString& file )
|
||||||
|
{
|
||||||
|
qDebug() << "Got csync statedb file: " << file;
|
||||||
|
_csyncStateDbFile = file;
|
||||||
|
}
|
||||||
|
|
||||||
void ownCloudFolder::slotCSyncTerminated()
|
void ownCloudFolder::slotCSyncTerminated()
|
||||||
{
|
{
|
||||||
// do not ask csync here for reasons.
|
// do not ask csync here for reasons.
|
||||||
|
@ -253,5 +261,31 @@ void ownCloudFolder::slotTerminateSync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This removes the csync File database if the sync folder definition is removed
|
||||||
|
// permanentely. This is needed to provide a clean startup again in case another
|
||||||
|
// local folder is synced to the same ownCloud.
|
||||||
|
// See http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-788
|
||||||
|
void ownCloudFolder::wipe()
|
||||||
|
{
|
||||||
|
if( !_csyncStateDbFile.isEmpty() ) {
|
||||||
|
QFile file(_csyncStateDbFile);
|
||||||
|
if( file.exists() ) {
|
||||||
|
if( !file.remove()) {
|
||||||
|
qDebug() << "WRN: Failed to remove existing csync StateDB " << _csyncStateDbFile;
|
||||||
|
} else {
|
||||||
|
qDebug() << "wipe: Removed csync StateDB " << _csyncStateDbFile;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "WRN: statedb is empty, can not remove.";
|
||||||
|
}
|
||||||
|
// Check if the tmp database file also exists
|
||||||
|
QString ctmpName = _csyncStateDbFile + ".ctmp";
|
||||||
|
QFile ctmpFile( ctmpName );
|
||||||
|
if( ctmpFile.exists() ) {
|
||||||
|
ctmpFile.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
virtual bool isBusy() const;
|
virtual bool isBusy() const;
|
||||||
virtual void startSync(const QStringList &pathList);
|
virtual void startSync(const QStringList &pathList);
|
||||||
|
|
||||||
|
virtual void wipe();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void startSync();
|
void startSync();
|
||||||
void slotTerminateSync();
|
void slotTerminateSync();
|
||||||
|
@ -48,6 +50,7 @@ private slots:
|
||||||
void slotCSyncFinished();
|
void slotCSyncFinished();
|
||||||
void slotThreadTreeWalkResult( WalkStats* );
|
void slotThreadTreeWalkResult( WalkStats* );
|
||||||
void slotCSyncTerminated();
|
void slotCSyncTerminated();
|
||||||
|
void slotCsyncStateDbFile(const QString&);
|
||||||
|
|
||||||
#ifndef USE_INOTIFY
|
#ifndef USE_INOTIFY
|
||||||
void slotPollTimerRemoteCheck();
|
void slotPollTimerRemoteCheck();
|
||||||
|
@ -62,6 +65,7 @@ private:
|
||||||
QStringList _errors;
|
QStringList _errors;
|
||||||
bool _csyncError;
|
bool _csyncError;
|
||||||
ulong _lastSeenFiles;
|
ulong _lastSeenFiles;
|
||||||
|
QString _csyncStateDbFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue