Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show the "All files deleted" popup when unselecting everything with selective sync #7530

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ void ProcessDirectoryJob::processBlacklisted(const PathTuple &path, const OCC::L
item->_file = path._target;
item->_originalFile = path._original;
item->_inode = localEntry.inode;
item->_isSelectiveSync = true;
if (dbEntry.isValid() && ((dbEntry._modtime == localEntry.modtime && dbEntry._fileSize == localEntry.size) || (localEntry.isDirectory && dbEntry.isDirectory()))) {
item->_instruction = CSYNC_INSTRUCTION_REMOVE;
item->_direction = SyncFileItem::Down;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
item->_status = SyncFileItem::Conflict;
}
return;
} else if (item->_instruction == CSYNC_INSTRUCTION_REMOVE) {
} else if (item->_instruction == CSYNC_INSTRUCTION_REMOVE && !item->_isSelectiveSync) {
_hasRemoveFile = true;
} else if (item->_instruction == CSYNC_INSTRUCTION_RENAME) {
_hasNoneFiles = true; // If a file (or every file) has been renamed, it means not al files where deleted
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/syncfileitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem
, _errorMayBeBlacklisted(false)
, _status(NoStatus)
, _isRestoration(false)
, _isSelectiveSync(false)
, _httpErrorCode(0)
, _affectedItems(1)
, _instruction(CSYNC_INSTRUCTION_NONE)
Expand Down Expand Up @@ -241,6 +242,7 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem
// Variables useful to report to the user
Status _status BITFIELD(4);
bool _isRestoration BITFIELD(1); // The original operation was forbidden, and this is a restoration
bool _isSelectiveSync BITFIELD(1); // The file is removed or ignored because it is in the selective sync list
quint16 _httpErrorCode;
RemotePermissions _remotePerm;
QString _errorString; // Contains a string only in case of error
Expand Down
26 changes: 26 additions & 0 deletions test/testallfilesdeleted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,32 @@ private slots:
QCOMPARE(aboutToRemoveAllFilesCalled, 0);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}

void testSelectiveSyncNoPopup() {
// Unselecting all folder should not cause the popup to be shown
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};

int aboutToRemoveAllFilesCalled = 0;
QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::aboutToRemoveAllFiles,
[&](SyncFileItem::Direction , bool *) {
aboutToRemoveAllFilesCalled++;
QFAIL("should not be called");
});

QVERIFY(fakeFolder.syncOnce());
QCOMPARE(aboutToRemoveAllFilesCalled, 0);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());

fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList,
QStringList() << "A/" << "B/" << "C/" << "S/");

QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), FileInfo{}); // all files should be one localy
QCOMPARE(fakeFolder.currentRemoteState(), FileInfo::A12_B12_C12_S12()); // Server not changed
QCOMPARE(aboutToRemoveAllFilesCalled, 0); // But we did not show the popup
}


};

QTEST_GUILESS_MAIN(TestAllFilesDeleted)
Expand Down