From 7e8b4031160028db86ee710e2b07b3f67d15fe69 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Thu, 22 May 2014 17:12:59 +0200 Subject: [PATCH] More progress on the CI problem detection. --- src/mirall/propagatorjobs.cpp | 28 +++++++++++++++++++++++++++- src/mirall/propagatorjobs.h | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/mirall/propagatorjobs.cpp b/src/mirall/propagatorjobs.cpp index 42ed45db67..6fab6a543e 100644 --- a/src/mirall/propagatorjobs.cpp +++ b/src/mirall/propagatorjobs.cpp @@ -99,6 +99,32 @@ void PropagateLocalRemove::start() done(SyncFileItem::Success); } +bool PropagateLocalMkdir::hasCaseClash( const QString& file ) +{ + bool re = false; + + qDebug() << "CaseClashCheck for " << file; +#ifdef Q_OS_WIN + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + + hFind = FindFirstFileW( (wchar_t*)file.utf16(), &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) { + qDebug() << "FindFirstFile failed " << GetLastError(); + // returns false. + } else { + QString realFileName = QString::fromWCharArray( FindFileData.cFileName ); + qDebug() << Q_FUNC_INFO << "Real file name is " << realFileName; + FindClose(hFind); + + if( ! file.endsWith(realFileName, Qt::CaseSensitive) ) { + re = true; + } + } +#endif + return re; +} + void PropagateLocalMkdir::start() { if (_propagator->_abortRequested.fetchAndAddRelaxed(0)) @@ -106,7 +132,7 @@ void PropagateLocalMkdir::start() QDir newDir(_propagator->_localDir + _item._file); QString newDirStr = QDir::toNativeSeparators(newDir.path()); - if(newDir.exists()) { + if(newDir.exists() && hasCaseClash(_propagator->_localDir + _item._file ) ) { // add a check on the file name qDebug() << "WARN: new directory to create locally already exists!"; done( SyncFileItem::NormalError, tr("Attention, possible case sensitivity clash with %1").arg(newDirStr) ); return; diff --git a/src/mirall/propagatorjobs.h b/src/mirall/propagatorjobs.h index 3b77e24e69..c256c05556 100644 --- a/src/mirall/propagatorjobs.h +++ b/src/mirall/propagatorjobs.h @@ -81,6 +81,7 @@ class PropagateLocalMkdir : public PropagateItemJob { public: PropagateLocalMkdir (OwncloudPropagator* propagator,const SyncFileItem& item) : PropagateItemJob(propagator, item) {} void start(); + bool hasCaseClash( const QString& file ); }; class PropagateRemoteRemove : public PropagateNeonJob { Q_OBJECT