diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 4d2c58cb326c8..0277698ceef64 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -133,26 +133,25 @@ OCSYNC_EXPORT bool csync_is_windows_reserved_word(const QStringView &filename) static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool excludeConflictFiles) { /* split up the path */ - QStringView bname(path); - int lastSlash = path.lastIndexOf(QLatin1Char('/')); - if (lastSlash >= 0) { - bname = path.mid(lastSlash + 1); + auto excludedFile = path; + if (const auto lastSlash = path.lastIndexOf(QLatin1Char('/'));lastSlash >= 0) { + excludedFile = path.mid(lastSlash + 1); } - qsizetype blen = bname.size(); + qsizetype blen = excludedFile.size(); // 9 = strlen(".sync_.db") - if (blen >= 9 && bname.at(0) == QLatin1Char('.')) { - if (bname.contains(QLatin1String(".db"))) { - if (bname.startsWith(QLatin1String("._sync_"), Qt::CaseInsensitive) // "._sync_*.db*" - || bname.startsWith(QLatin1String(".sync_"), Qt::CaseInsensitive) // ".sync_*.db*" - || bname.startsWith(QLatin1String(".csync_journal.db"), Qt::CaseInsensitive)) { // ".csync_journal.db*" + if (blen >= 9 && excludedFile.at(0) == QLatin1Char('.')) { + if (excludedFile.contains(QLatin1String(".db"))) { + if (excludedFile.startsWith(QLatin1String("._sync_"), Qt::CaseInsensitive) // "._sync_*.db*" + || excludedFile.startsWith(QLatin1String(".sync_"), Qt::CaseInsensitive) // ".sync_*.db*" + || excludedFile.startsWith(QLatin1String(".csync_journal.db"), Qt::CaseInsensitive)) { // ".csync_journal.db*" return CSYNC_FILE_SILENTLY_EXCLUDED; } } - if (bname.startsWith(QLatin1String(".owncloudsync.log"), Qt::CaseInsensitive)) { // ".owncloudsync.log*" + if (excludedFile.startsWith(QLatin1String(".owncloudsync.log"), Qt::CaseInsensitive)) { // ".owncloudsync.log*" return CSYNC_FILE_SILENTLY_EXCLUDED; } - if (bname.startsWith(QLatin1String(".nextcloudsync.log"), Qt::CaseInsensitive)) { // ".nextcloudsync.log*" + if (excludedFile.startsWith(QLatin1String(".nextcloudsync.log"), Qt::CaseInsensitive)) { // ".nextcloudsync.log*" return CSYNC_FILE_SILENTLY_EXCLUDED; } } @@ -202,7 +201,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu /* Do not sync desktop.ini files anywhere in the tree. */ const auto desktopIniFile = QStringLiteral("desktop.ini"); - if (blen == static_cast(desktopIniFile.length()) && bname.compare(desktopIniFile, Qt::CaseInsensitive) == 0) { + if (blen == static_cast(desktopIniFile.length()) && excludedFile.compare(desktopIniFile, Qt::CaseInsensitive) == 0) { return CSYNC_FILE_SILENTLY_EXCLUDED; }