Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-01-19 11:12:16 +0300
committerHannah von Reth <hannah.vonreth@owncloud.com>2021-01-19 11:12:16 +0300
commit88886e410cea1ff6123cf3d8f4528f61a26dea40 (patch)
treedd1197ea14ae297d2c08657a3000da3716e2e31f /src
parentd19ffc2953e3a3bfbc183ebf36238dd21f24cf9c (diff)
parente25f1b27b995bb050e7a5cf9108f8895923b65d6 (diff)
Merge branch 'work/v2.7.5' into 2.7
Diffstat (limited to 'src')
-rw-r--r--src/libsync/owncloudpropagator.cpp25
-rw-r--r--src/libsync/propagatedownload.cpp5
2 files changed, 18 insertions, 12 deletions
diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp
index c7877efaf..cd87a3ef0 100644
--- a/src/libsync/owncloudpropagator.cpp
+++ b/src/libsync/owncloudpropagator.cpp
@@ -513,24 +513,25 @@ 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)
- const QString file(_localDir + relFile);
- qCDebug(lcPropagator) << "CaseClashCheck for " << file;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
@@ -538,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
@@ -551,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)
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index c75426e02..194fc1cbc 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -381,6 +381,11 @@ void PropagateDownloadFile::start()
}
if (_item->_type == ItemTypeVirtualFile) {
qCDebug(lcPropagateDownload) << "creating virtual file" << _item->_file;
+ // do a klaas' case clash check.
+ if (propagator()->localFileNameClash(_item->_file)) {
+ done(SyncFileItem::NormalError, tr("File %1 can not be downloaded because of a local file name clash!").arg(QDir::toNativeSeparators(_item->_file)));
+ return;
+ }
auto r = vfs->createPlaceholder(*_item);
if (!r) {
done(SyncFileItem::NormalError, r.error());