diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-01-05 12:58:53 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-01-19 10:59:49 +0300 |
commit | a9c7420e4cf743b780594a138b2c3d43e73efa9d (patch) | |
tree | 443d628f3b2724befb29ea12ab5cada67b602836 /src | |
parent | 7f039c608b7424ac2893b0d42c240659bd8a6d28 (diff) |
Small cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/libsync/owncloudpropagator.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 8fcd23b2e..cd87a3ef0 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -513,21 +513,23 @@ void OwncloudPropagator::setSyncOptions(const SyncOptions &syncOptions) bool OwncloudPropagator::localFileNameClash(const QString &relFile) { - bool re = false; const QString file(_localDir + relFile); + OC_ASSERT(!file.isEmpty()); if (!file.isEmpty() && Utility::fsCasePreserving()) { qCDebug(lcPropagator) << "CaseClashCheck for " << file; #ifdef Q_OS_MAC - QFileInfo fileInfo(file); + const QFileInfo fileInfo(file); if (!fileInfo.exists()) { - re = false; qCWarning(lcPropagator) << "No valid fileinfo"; + return false; } else { // Need to normalize to composited form because of QTBUG-39622/QTBUG-55896 const QString cName = fileInfo.canonicalFilePath().normalized(QString::NormalizationForm_C); - bool equal = (file == cName); - re = (!equal && !cName.endsWith(relFile, Qt::CaseSensitive)); + if (file != cName && !cName.endsWith(relFile, Qt::CaseSensitive)) { + qCWarning(lcPropagator) << "Detected case clash between" << file << "and" << cName; + return true; + } } #elif defined(Q_OS_WIN) WIN32_FIND_DATA FindFileData; @@ -537,12 +539,12 @@ bool OwncloudPropagator::localFileNameClash(const QString &relFile) if (hFind == INVALID_HANDLE_VALUE) { // returns false. } else { - QString realFileName = QString::fromWCharArray(FindFileData.cFileName); + const QString realFileName = QString::fromWCharArray(FindFileData.cFileName); FindClose(hFind); if (!file.endsWith(realFileName, Qt::CaseSensitive)) { qCWarning(lcPropagator) << "Detected case clash between" << file << "and" << realFileName; - re = true; + return true; } } #else @@ -550,13 +552,13 @@ bool OwncloudPropagator::localFileNameClash(const QString &relFile) // Just check that there is no other file with the same name and different casing. QFileInfo fileInfo(file); const QString fn = fileInfo.fileName(); - QStringList list = fileInfo.dir().entryList(QStringList() << fn); + const QStringList list = fileInfo.dir().entryList({ fn }); if (list.count() > 1 || (list.count() == 1 && list[0] != fn)) { - re = true; + return true; } #endif } - return re; + return false; } bool OwncloudPropagator::hasCaseClashAccessibilityProblem(const QString &relfile) |