SyncFileStatusTracker: Distinguish Warning and Excluded

Any folder with a (potentially deeply) contained error will have
StatusWarning. StatusExcluded marks exclusions. The difference is useful
to know for VFS.
This commit is contained in:
Christian Kamm 2019-01-25 11:09:50 +01:00 коммит произвёл Kevin Ottens
Родитель 7f400e3226
Коммит 01f7bc7b49
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 074BBBCB8DECC9E2
4 изменённых файлов: 24 добавлений и 19 удалений

Просмотреть файл

@ -65,6 +65,10 @@ QString SyncFileStatus::toSocketAPIString() const
case StatusError:
statusString = QLatin1String("ERROR");
break;
case StatusExcluded:
// The protocol says IGNORE, but all implementations show a yellow warning sign.
statusString = QLatin1String("IGNORE");
break;
}
if (canBeShared && _shared) {
statusString += QLatin1String("+SWM");

Просмотреть файл

@ -36,6 +36,7 @@ public:
StatusWarning,
StatusUpToDate,
StatusError,
StatusExcluded,
};
SyncFileStatus();

Просмотреть файл

@ -89,7 +89,7 @@ SyncFileStatus::SyncFileStatusTag SyncFileStatusTracker::lookupProblem(const QSt
* icon as the problem is most likely going to resolve itself quickly and
* automatically.
*/
static inline bool showErrorInSocketApi(const SyncFileItem &item)
static inline bool hasErrorStatus(const SyncFileItem &item)
{
const auto status = item._status;
return item._instruction == CSYNC_INSTRUCTION_ERROR
@ -100,7 +100,7 @@ static inline bool showErrorInSocketApi(const SyncFileItem &item)
|| item._hasBlacklistEntry;
}
static inline bool showWarningInSocketApi(const SyncFileItem &item)
static inline bool hasExcludedStatus(const SyncFileItem &item)
{
const auto status = item._status;
return item._instruction == CSYNC_INSTRUCTION_IGNORE
@ -142,7 +142,7 @@ SyncFileStatus SyncFileStatusTracker::fileStatus(const QString &relativePath)
if (_syncEngine->excludedFiles().isExcluded(_syncEngine->localPath() + relativePath,
_syncEngine->localPath(),
_syncEngine->ignoreHiddenFiles())) {
return SyncFileStatus::StatusWarning;
return SyncFileStatus::StatusExcluded;
}
if (_dirtyPaths.contains(relativePath))
@ -171,7 +171,7 @@ void SyncFileStatusTracker::slotPathTouched(const QString &fileName)
void SyncFileStatusTracker::slotAddSilentlyExcluded(const QString &folderPath)
{
_syncProblems[folderPath] = SyncFileStatus::StatusWarning;
_syncProblems[folderPath] = SyncFileStatus::StatusExcluded;
emit fileStatusChanged(getSystemDestination(folderPath), resolveSyncAndErrorStatus(folderPath, NotShared));
}
@ -229,11 +229,11 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
qCDebug(lcStatusTracker) << "Investigating" << item->destination() << item->_status << item->_instruction;
_dirtyPaths.remove(item->destination());
if (showErrorInSocketApi(*item)) {
if (hasErrorStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusError;
invalidateParentPaths(item->destination());
} else if (showWarningInSocketApi(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusWarning;
} else if (hasExcludedStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusExcluded;
}
SharedFlag sharedFlag = item->_remotePerm.hasPermission(RemotePermissions::IsShared) ? Shared : NotShared;
@ -273,11 +273,11 @@ void SyncFileStatusTracker::slotItemCompleted(const SyncFileItemPtr &item)
{
qCDebug(lcStatusTracker) << "Item completed" << item->destination() << item->_status << item->_instruction;
if (showErrorInSocketApi(*item)) {
if (hasErrorStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusError;
invalidateParentPaths(item->destination());
} else if (showWarningInSocketApi(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusWarning;
} else if (hasExcludedStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusExcluded;
} else {
_syncProblems.erase(item->_file);
}

Просмотреть файл

@ -222,19 +222,19 @@ private slots:
fakeFolder.scheduleSync();
fakeFolder.execUntilBeforePropagation();
verifyThatPushMatchesPull(fakeFolder, statusSpy);
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusExcluded));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusExcluded));
QEXPECT_FAIL("", "csync will stop at ignored directories without traversing children, so we don't currently push the status for newly ignored children of an ignored directory.", Continue);
QCOMPARE(statusSpy.statusOf("B/b1"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B/b1"), SyncFileStatus(SyncFileStatus::StatusExcluded));
fakeFolder.execUntilFinished();
verifyThatPushMatchesPull(fakeFolder, statusSpy);
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusExcluded));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusExcluded));
QEXPECT_FAIL("", "csync will stop at ignored directories without traversing children, so we don't currently push the status for newly ignored children of an ignored directory.", Continue);
QCOMPARE(statusSpy.statusOf("B/b1"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B/b1"), SyncFileStatus(SyncFileStatus::StatusExcluded));
QEXPECT_FAIL("", "csync will stop at ignored directories without traversing children, so we don't currently push the status for newly ignored children of an ignored directory.", Continue);
QCOMPARE(statusSpy.statusOf("B/b2"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B/b2"), SyncFileStatus(SyncFileStatus::StatusExcluded));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus(""), SyncFileStatus(SyncFileStatus::StatusUpToDate));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
statusSpy.clear();
@ -271,12 +271,12 @@ private slots:
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus(""), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A/a1"), SyncFileStatus(SyncFileStatus::StatusError));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("B"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("B"), SyncFileStatus(SyncFileStatus::StatusExcluded));
// Should still get the status for different casing on macOS and Windows.
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("a"), SyncFileStatus(Utility::fsCasePreserving() ? SyncFileStatus::StatusWarning : SyncFileStatus::StatusNone));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A/A1"), SyncFileStatus(Utility::fsCasePreserving() ? SyncFileStatus::StatusError : SyncFileStatus::StatusNone));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("b"), SyncFileStatus(Utility::fsCasePreserving() ? SyncFileStatus::StatusWarning : SyncFileStatus::StatusNone));
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("b"), SyncFileStatus(Utility::fsCasePreserving() ? SyncFileStatus::StatusExcluded : SyncFileStatus::StatusNone));
}
void parentsGetWarningStatusForError() {