зеркало из https://github.com/nextcloud/desktop.git
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:
Родитель
7f400e3226
Коммит
01f7bc7b49
|
@ -65,6 +65,10 @@ QString SyncFileStatus::toSocketAPIString() const
|
||||||
case StatusError:
|
case StatusError:
|
||||||
statusString = QLatin1String("ERROR");
|
statusString = QLatin1String("ERROR");
|
||||||
break;
|
break;
|
||||||
|
case StatusExcluded:
|
||||||
|
// The protocol says IGNORE, but all implementations show a yellow warning sign.
|
||||||
|
statusString = QLatin1String("IGNORE");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (canBeShared && _shared) {
|
if (canBeShared && _shared) {
|
||||||
statusString += QLatin1String("+SWM");
|
statusString += QLatin1String("+SWM");
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
StatusWarning,
|
StatusWarning,
|
||||||
StatusUpToDate,
|
StatusUpToDate,
|
||||||
StatusError,
|
StatusError,
|
||||||
|
StatusExcluded,
|
||||||
};
|
};
|
||||||
|
|
||||||
SyncFileStatus();
|
SyncFileStatus();
|
||||||
|
|
|
@ -89,7 +89,7 @@ SyncFileStatus::SyncFileStatusTag SyncFileStatusTracker::lookupProblem(const QSt
|
||||||
* icon as the problem is most likely going to resolve itself quickly and
|
* icon as the problem is most likely going to resolve itself quickly and
|
||||||
* automatically.
|
* automatically.
|
||||||
*/
|
*/
|
||||||
static inline bool showErrorInSocketApi(const SyncFileItem &item)
|
static inline bool hasErrorStatus(const SyncFileItem &item)
|
||||||
{
|
{
|
||||||
const auto status = item._status;
|
const auto status = item._status;
|
||||||
return item._instruction == CSYNC_INSTRUCTION_ERROR
|
return item._instruction == CSYNC_INSTRUCTION_ERROR
|
||||||
|
@ -100,7 +100,7 @@ static inline bool showErrorInSocketApi(const SyncFileItem &item)
|
||||||
|| item._hasBlacklistEntry;
|
|| item._hasBlacklistEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool showWarningInSocketApi(const SyncFileItem &item)
|
static inline bool hasExcludedStatus(const SyncFileItem &item)
|
||||||
{
|
{
|
||||||
const auto status = item._status;
|
const auto status = item._status;
|
||||||
return item._instruction == CSYNC_INSTRUCTION_IGNORE
|
return item._instruction == CSYNC_INSTRUCTION_IGNORE
|
||||||
|
@ -142,7 +142,7 @@ SyncFileStatus SyncFileStatusTracker::fileStatus(const QString &relativePath)
|
||||||
if (_syncEngine->excludedFiles().isExcluded(_syncEngine->localPath() + relativePath,
|
if (_syncEngine->excludedFiles().isExcluded(_syncEngine->localPath() + relativePath,
|
||||||
_syncEngine->localPath(),
|
_syncEngine->localPath(),
|
||||||
_syncEngine->ignoreHiddenFiles())) {
|
_syncEngine->ignoreHiddenFiles())) {
|
||||||
return SyncFileStatus::StatusWarning;
|
return SyncFileStatus::StatusExcluded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dirtyPaths.contains(relativePath))
|
if (_dirtyPaths.contains(relativePath))
|
||||||
|
@ -171,7 +171,7 @@ void SyncFileStatusTracker::slotPathTouched(const QString &fileName)
|
||||||
|
|
||||||
void SyncFileStatusTracker::slotAddSilentlyExcluded(const QString &folderPath)
|
void SyncFileStatusTracker::slotAddSilentlyExcluded(const QString &folderPath)
|
||||||
{
|
{
|
||||||
_syncProblems[folderPath] = SyncFileStatus::StatusWarning;
|
_syncProblems[folderPath] = SyncFileStatus::StatusExcluded;
|
||||||
emit fileStatusChanged(getSystemDestination(folderPath), resolveSyncAndErrorStatus(folderPath, NotShared));
|
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;
|
qCDebug(lcStatusTracker) << "Investigating" << item->destination() << item->_status << item->_instruction;
|
||||||
_dirtyPaths.remove(item->destination());
|
_dirtyPaths.remove(item->destination());
|
||||||
|
|
||||||
if (showErrorInSocketApi(*item)) {
|
if (hasErrorStatus(*item)) {
|
||||||
_syncProblems[item->_file] = SyncFileStatus::StatusError;
|
_syncProblems[item->_file] = SyncFileStatus::StatusError;
|
||||||
invalidateParentPaths(item->destination());
|
invalidateParentPaths(item->destination());
|
||||||
} else if (showWarningInSocketApi(*item)) {
|
} else if (hasExcludedStatus(*item)) {
|
||||||
_syncProblems[item->_file] = SyncFileStatus::StatusWarning;
|
_syncProblems[item->_file] = SyncFileStatus::StatusExcluded;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedFlag sharedFlag = item->_remotePerm.hasPermission(RemotePermissions::IsShared) ? Shared : NotShared;
|
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;
|
qCDebug(lcStatusTracker) << "Item completed" << item->destination() << item->_status << item->_instruction;
|
||||||
|
|
||||||
if (showErrorInSocketApi(*item)) {
|
if (hasErrorStatus(*item)) {
|
||||||
_syncProblems[item->_file] = SyncFileStatus::StatusError;
|
_syncProblems[item->_file] = SyncFileStatus::StatusError;
|
||||||
invalidateParentPaths(item->destination());
|
invalidateParentPaths(item->destination());
|
||||||
} else if (showWarningInSocketApi(*item)) {
|
} else if (hasExcludedStatus(*item)) {
|
||||||
_syncProblems[item->_file] = SyncFileStatus::StatusWarning;
|
_syncProblems[item->_file] = SyncFileStatus::StatusExcluded;
|
||||||
} else {
|
} else {
|
||||||
_syncProblems.erase(item->_file);
|
_syncProblems.erase(item->_file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,19 +222,19 @@ private slots:
|
||||||
fakeFolder.scheduleSync();
|
fakeFolder.scheduleSync();
|
||||||
fakeFolder.execUntilBeforePropagation();
|
fakeFolder.execUntilBeforePropagation();
|
||||||
verifyThatPushMatchesPull(fakeFolder, statusSpy);
|
verifyThatPushMatchesPull(fakeFolder, statusSpy);
|
||||||
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusWarning));
|
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusExcluded));
|
||||||
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusWarning));
|
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);
|
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();
|
fakeFolder.execUntilFinished();
|
||||||
verifyThatPushMatchesPull(fakeFolder, statusSpy);
|
verifyThatPushMatchesPull(fakeFolder, statusSpy);
|
||||||
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusWarning));
|
QCOMPARE(statusSpy.statusOf("A/a1"), SyncFileStatus(SyncFileStatus::StatusExcluded));
|
||||||
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusWarning));
|
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);
|
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);
|
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(""), SyncFileStatus(SyncFileStatus::StatusUpToDate));
|
||||||
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
|
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
|
||||||
statusSpy.clear();
|
statusSpy.clear();
|
||||||
|
@ -271,12 +271,12 @@ private slots:
|
||||||
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus(""), SyncFileStatus(SyncFileStatus::StatusWarning));
|
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus(""), SyncFileStatus(SyncFileStatus::StatusWarning));
|
||||||
QCOMPARE(fakeFolder.syncEngine().syncFileStatusTracker().fileStatus("A"), 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("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.
|
// 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"), 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("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() {
|
void parentsGetWarningStatusForError() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче