mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Use another way to detect that the server was reconfigured
Before, we would only detect it if all the files were removed, and no file where added or changed. This may not be enough because there might be a welcome.txt file. Now, we check that none of the file stays the same, and some files are removed. Relates issue #1948
This commit is contained in:
parent
51e9c5fd96
commit
d697969f36
3 changed files with 17 additions and 16 deletions
|
@ -704,10 +704,7 @@ void Folder::slotTransmissionProgress(const Progress::Info &pi)
|
||||||
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel)
|
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel)
|
||||||
{
|
{
|
||||||
#ifndef TOKEN_AUTH_ONLY
|
#ifndef TOKEN_AUTH_ONLY
|
||||||
QString msg = direction == SyncFileItem::Down ?
|
QString msg =
|
||||||
tr("This sync would remove all the files in the local sync folder '%1'.\n"
|
|
||||||
"If you or your administrator have reset your account on the server, choose "
|
|
||||||
"\"Keep files\". If you want your data to be removed, choose \"Remove all files\".") :
|
|
||||||
tr("This sync would remove all the files in the sync folder '%1'.\n"
|
tr("This sync would remove all the files in the sync folder '%1'.\n"
|
||||||
"This might be because the folder was silently reconfigured, or that all "
|
"This might be because the folder was silently reconfigured, or that all "
|
||||||
"the file were manually removed.\n"
|
"the file were manually removed.\n"
|
||||||
|
|
|
@ -61,7 +61,8 @@ SyncEngine::SyncEngine(CSYNC *ctx, const QString& localPath, const QString& remo
|
||||||
, _remoteUrl(remoteURL)
|
, _remoteUrl(remoteURL)
|
||||||
, _remotePath(remotePath)
|
, _remotePath(remotePath)
|
||||||
, _journal(journal)
|
, _journal(journal)
|
||||||
, _hasFiles(false)
|
, _hasNoneFiles(false)
|
||||||
|
, _hasRemoveFile(false)
|
||||||
, _downloadLimit(0)
|
, _downloadLimit(0)
|
||||||
, _uploadLimit(0)
|
, _uploadLimit(0)
|
||||||
|
|
||||||
|
@ -330,7 +331,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||||
dir = SyncFileItem::None;
|
dir = SyncFileItem::None;
|
||||||
} else {
|
} else {
|
||||||
// No need to do anything.
|
// No need to do anything.
|
||||||
_hasFiles = true;
|
_hasNoneFiles = true;
|
||||||
|
|
||||||
emit syncItemDiscovered(item);
|
emit syncItemDiscovered(item);
|
||||||
return re;
|
return re;
|
||||||
|
@ -343,8 +344,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||||
_renamedFolders.insert(item._file, item._renameTarget);
|
_renamedFolders.insert(item._file, item._renameTarget);
|
||||||
break;
|
break;
|
||||||
case CSYNC_INSTRUCTION_REMOVE:
|
case CSYNC_INSTRUCTION_REMOVE:
|
||||||
|
_hasRemoveFile = true;
|
||||||
dir = !remote ? SyncFileItem::Down : SyncFileItem::Up;
|
dir = !remote ? SyncFileItem::Down : SyncFileItem::Up;
|
||||||
break;
|
break;
|
||||||
case CSYNC_INSTRUCTION_CONFLICT:
|
case CSYNC_INSTRUCTION_CONFLICT:
|
||||||
case CSYNC_INSTRUCTION_IGNORE:
|
case CSYNC_INSTRUCTION_IGNORE:
|
||||||
case CSYNC_INSTRUCTION_ERROR:
|
case CSYNC_INSTRUCTION_ERROR:
|
||||||
|
@ -356,6 +358,11 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||||
case CSYNC_INSTRUCTION_STAT_ERROR:
|
case CSYNC_INSTRUCTION_STAT_ERROR:
|
||||||
default:
|
default:
|
||||||
dir = remote ? SyncFileItem::Down : SyncFileItem::Up;
|
dir = remote ? SyncFileItem::Down : SyncFileItem::Up;
|
||||||
|
if (!remote && file->instruction == CSYNC_INSTRUCTION_SYNC) {
|
||||||
|
// An upload of an existing file means that the file was left unchanged on the server
|
||||||
|
// This count as a NONE for detecting if all the file on the server were changed
|
||||||
|
_hasNoneFiles = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,11 +371,6 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||||
// if the item is on blacklist, the instruction was set to IGNORE
|
// if the item is on blacklist, the instruction was set to IGNORE
|
||||||
checkBlacklisting( &item );
|
checkBlacklisting( &item );
|
||||||
|
|
||||||
if (file->instruction != CSYNC_INSTRUCTION_IGNORE
|
|
||||||
&& file->instruction != CSYNC_INSTRUCTION_REMOVE) {
|
|
||||||
_hasFiles = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!item._isDirectory) {
|
if (!item._isDirectory) {
|
||||||
_progressInfo._totalFileCount++;
|
_progressInfo._totalFileCount++;
|
||||||
if (Progress::isSizeDependent(file->instruction)) {
|
if (Progress::isSizeDependent(file->instruction)) {
|
||||||
|
@ -526,7 +528,8 @@ void SyncEngine::slotUpdateFinished(int updateResult)
|
||||||
|
|
||||||
_progressInfo = Progress::Info();
|
_progressInfo = Progress::Info();
|
||||||
|
|
||||||
_hasFiles = false;
|
_hasNoneFiles = false;
|
||||||
|
_hasRemoveFile = false;
|
||||||
bool walkOk = true;
|
bool walkOk = true;
|
||||||
_seenFiles.clear();
|
_seenFiles.clear();
|
||||||
|
|
||||||
|
@ -556,8 +559,8 @@ void SyncEngine::slotUpdateFinished(int updateResult)
|
||||||
emit aboutToPropagate(_syncedItems);
|
emit aboutToPropagate(_syncedItems);
|
||||||
emit transmissionProgress(_progressInfo);
|
emit transmissionProgress(_progressInfo);
|
||||||
|
|
||||||
if (!_hasFiles && !_syncedItems.isEmpty()) {
|
if (!_hasNoneFiles && _hasRemoveFile) {
|
||||||
qDebug() << Q_FUNC_INFO << "All the files are going to be removed, asking the user";
|
qDebug() << Q_FUNC_INFO << "All the files are going to be changed, asking the user";
|
||||||
bool cancel = false;
|
bool cancel = false;
|
||||||
emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
|
emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
|
|
|
@ -127,7 +127,8 @@ private:
|
||||||
QHash<QString, QString> _renamedFolders;
|
QHash<QString, QString> _renamedFolders;
|
||||||
QString adjustRenamedPath(const QString &original);
|
QString adjustRenamedPath(const QString &original);
|
||||||
|
|
||||||
bool _hasFiles; // true if there is at least one file that is not ignored or removed
|
bool _hasNoneFiles; // true if there is at least one file with instruction NONE
|
||||||
|
bool _hasRemoveFile; // true if there is at leasr one file with instruction REMOVE
|
||||||
|
|
||||||
int _downloadLimit;
|
int _downloadLimit;
|
||||||
int _uploadLimit;
|
int _uploadLimit;
|
||||||
|
|
Loading…
Reference in a new issue