mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
Merge pull request #3260 from nextcloud/fix/cherryPickFixes
Fix/cherry pick fixes
This commit is contained in:
commit
8f7646d93f
10 changed files with 34 additions and 29 deletions
|
@ -72,7 +72,7 @@ IFACEMETHODIMP_(ULONG) NCContextMenu::Release()
|
||||||
|
|
||||||
// Initialize the context menu handler.
|
// Initialize the context menu handler.
|
||||||
IFACEMETHODIMP NCContextMenu::Initialize(
|
IFACEMETHODIMP NCContextMenu::Initialize(
|
||||||
LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hKeyProgID)
|
LPCITEMIDLIST, LPDATAOBJECT pDataObj, HKEY)
|
||||||
{
|
{
|
||||||
m_selectedFiles.clear();
|
m_selectedFiles.clear();
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ bool FileSystem::rename(const QString &originFileName,
|
||||||
(wchar_t *)dest.utf16(),
|
(wchar_t *)dest.utf16(),
|
||||||
MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH);
|
MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
error = Utility::formatLastWinError();
|
error = Utility::formatWinError(GetLastError());
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -275,20 +275,19 @@ int SqlQuery::prepare(const QByteArray &sql, bool allow_failure)
|
||||||
* There is no overloads to QByteArray::startWith that takes Qt::CaseInsensitive.
|
* There is no overloads to QByteArray::startWith that takes Qt::CaseInsensitive.
|
||||||
* Returns true if 'a' starts with 'b' in a case insensitive way
|
* Returns true if 'a' starts with 'b' in a case insensitive way
|
||||||
*/
|
*/
|
||||||
static bool startsWithInsensitive(const QByteArray &a, const char *b)
|
static bool startsWithInsensitive(const QByteArray &a, const QByteArray &b)
|
||||||
{
|
{
|
||||||
size_t len = strlen(b);
|
return a.size() >= b.size() && qstrnicmp(a.constData(), b.constData(), static_cast<uint>(b.size())) == 0;
|
||||||
return a.size() >= len && qstrnicmp(a.constData(), b, Utility::convertSizeToUint(len)) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqlQuery::isSelect()
|
bool SqlQuery::isSelect()
|
||||||
{
|
{
|
||||||
return startsWithInsensitive(_sql, "SELECT");
|
return startsWithInsensitive(_sql, QByteArrayLiteral("SELECT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqlQuery::isPragma()
|
bool SqlQuery::isPragma()
|
||||||
{
|
{
|
||||||
return startsWithInsensitive(_sql, "PRAGMA");
|
return startsWithInsensitive(_sql, QByteArrayLiteral("PRAGMA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqlQuery::exec()
|
bool SqlQuery::exec()
|
||||||
|
|
|
@ -250,9 +250,6 @@ namespace Utility {
|
||||||
OCSYNC_EXPORT void UnixTimeToLargeIntegerFiletime(time_t t, LARGE_INTEGER *hundredNSecs);
|
OCSYNC_EXPORT void UnixTimeToLargeIntegerFiletime(time_t t, LARGE_INTEGER *hundredNSecs);
|
||||||
|
|
||||||
OCSYNC_EXPORT QString formatWinError(long error);
|
OCSYNC_EXPORT QString formatWinError(long error);
|
||||||
inline QString formatLastWinError() {
|
|
||||||
return formatWinError(GetLastError());
|
|
||||||
};
|
|
||||||
|
|
||||||
class OCSYNC_EXPORT NtfsPermissionLookupRAII
|
class OCSYNC_EXPORT NtfsPermissionLookupRAII
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ OCSYNC_EXPORT void csync_exclude_expand_escapes(QByteArray &input)
|
||||||
line[o++] = line[i];
|
line[o++] = line[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input.resize(OCC::Utility::convertSizeToUint(o));
|
input.resize(OCC::Utility::convertSizeToInt(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
// See http://support.microsoft.com/kb/74496 and
|
// See http://support.microsoft.com/kb/74496 and
|
||||||
|
@ -139,7 +139,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu
|
||||||
bname = path.midRef(lastSlash + 1);
|
bname = path.midRef(lastSlash + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t blen = bname.size();
|
qsizetype blen = bname.size();
|
||||||
// 9 = strlen(".sync_.db")
|
// 9 = strlen(".sync_.db")
|
||||||
if (blen >= 9 && bname.at(0) == QLatin1Char('.')) {
|
if (blen >= 9 && bname.at(0) == QLatin1Char('.')) {
|
||||||
if (bname.contains(QLatin1String(".db"))) {
|
if (bname.contains(QLatin1String(".db"))) {
|
||||||
|
|
|
@ -45,7 +45,8 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
if (_directory == INVALID_HANDLE_VALUE) {
|
if (_directory == INVALID_HANDLE_VALUE) {
|
||||||
qCWarning(lcFolderWatcher) << "Failed to create handle for" << _path << ", error:" << Utility::formatLastWinError();
|
const auto error = GetLastError();
|
||||||
|
qCWarning(lcFolderWatcher) << "Failed to create handle for" << _path << ", error:" << Utility::formatWinError(error);
|
||||||
_directory = 0;
|
_directory = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,12 +95,13 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize,
|
||||||
2, handles,
|
2, handles,
|
||||||
false, // awake once one of them arrives
|
false, // awake once one of them arrives
|
||||||
INFINITE);
|
INFINITE);
|
||||||
|
const auto error = GetLastError();
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
qCDebug(lcFolderWatcher) << "Received stop event, aborting folder watcher thread";
|
qCDebug(lcFolderWatcher) << "Received stop event, aborting folder watcher thread";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
qCWarning(lcFolderWatcher) << "WaitForMultipleObjects failed" << result << Utility::formatLastWinError();
|
qCWarning(lcFolderWatcher) << "WaitForMultipleObjects failed" << result << Utility::formatWinError(error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,10 +130,11 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize,
|
||||||
&& curEntry->Action != FILE_ACTION_RENAMED_OLD_NAME) {
|
&& curEntry->Action != FILE_ACTION_RENAMED_OLD_NAME) {
|
||||||
const auto wfile = longfile.toStdWString();
|
const auto wfile = longfile.toStdWString();
|
||||||
const int longNameSize = GetLongPathNameW(wfile.data(), fileNameBuffer, fileNameBufferSize);
|
const int longNameSize = GetLongPathNameW(wfile.data(), fileNameBuffer, fileNameBufferSize);
|
||||||
|
const auto error = GetLastError();
|
||||||
if (longNameSize > 0) {
|
if (longNameSize > 0) {
|
||||||
longfile = QString::fromWCharArray(fileNameBuffer, longNameSize);
|
longfile = QString::fromWCharArray(fileNameBuffer, longNameSize);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(lcFolderWatcher) << "Error converting file name" << longfile << "to full length, keeping original name." << Utility::formatLastWinError();
|
qCWarning(lcFolderWatcher) << "Error converting file name" << longfile << "to full length, keeping original name." << Utility::formatWinError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ AccessManager::AccessManager(QObject *parent)
|
||||||
setCookieJar(new CookieJar);
|
setCookieJar(new CookieJar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QByteArray generateRequestId()
|
QByteArray AccessManager::generateRequestId()
|
||||||
{
|
{
|
||||||
// Use a UUID with the starting and ending curly brace removed.
|
// Use a UUID with the starting and ending curly brace removed.
|
||||||
auto uuid = QUuid::createUuid().toByteArray();
|
auto uuid = QUuid::createUuid().toByteArray();
|
||||||
|
|
|
@ -32,6 +32,8 @@ class OWNCLOUDSYNC_EXPORT AccessManager : public QNetworkAccessManager
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static QByteArray generateRequestId();
|
||||||
|
|
||||||
AccessManager(QObject *parent = nullptr);
|
AccessManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -885,16 +885,15 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
|
||||||
item->_type = localEntry.isDirectory ? ItemTypeDirectory : localEntry.isVirtualFile ? ItemTypeVirtualFile : ItemTypeFile;
|
item->_type = localEntry.isDirectory ? ItemTypeDirectory : localEntry.isVirtualFile ? ItemTypeVirtualFile : ItemTypeFile;
|
||||||
_childModified = true;
|
_childModified = true;
|
||||||
|
|
||||||
auto postProcessLocalNew = [item, localEntry, this]() {
|
auto postProcessLocalNew = [item, localEntry, path, this]() {
|
||||||
if (localEntry.isVirtualFile) {
|
if (localEntry.isVirtualFile) {
|
||||||
// Remove the spurious file if it looks like a placeholder file
|
const bool isPlaceHolder = _discoveryData->_syncOptions._vfs->isDehydratedPlaceholder(_discoveryData->_localDir + path._local);
|
||||||
// (we know placeholder files contain " ", but only in the suffix case)
|
if (isPlaceHolder) {
|
||||||
if (localEntry.size <= 1 || !isVfsWithSuffix()) {
|
qCWarning(lcDisco) << "Wiping virtual file without db entry for" << path._local;
|
||||||
qCWarning(lcDisco) << "Wiping virtual file without db entry for" << _currentFolder._local + "/" + localEntry.name;
|
|
||||||
item->_instruction = CSYNC_INSTRUCTION_REMOVE;
|
item->_instruction = CSYNC_INSTRUCTION_REMOVE;
|
||||||
item->_direction = SyncFileItem::Down;
|
item->_direction = SyncFileItem::Down;
|
||||||
} else {
|
} else {
|
||||||
qCWarning(lcDisco) << "Virtual file without db entry for" << _currentFolder._local << localEntry.name
|
qCWarning(lcDisco) << "Virtual file without db entry for" << path._local
|
||||||
<< "but looks odd, keeping";
|
<< "but looks odd, keeping";
|
||||||
item->_instruction = CSYNC_INSTRUCTION_IGNORE;
|
item->_instruction = CSYNC_INSTRUCTION_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "syncenginetestutils.h"
|
#include "syncenginetestutils.h"
|
||||||
|
#include "httplogger.h"
|
||||||
|
#include "accessmanager.h"
|
||||||
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -803,27 +805,30 @@ QNetworkReply *FakeQNAM::createRequest(QNetworkAccessManager::Operation op, cons
|
||||||
bool isUpload = request.url().path().startsWith(sUploadUrl.path());
|
bool isUpload = request.url().path().startsWith(sUploadUrl.path());
|
||||||
FileInfo &info = isUpload ? _uploadFileInfo : _remoteRootFileInfo;
|
FileInfo &info = isUpload ? _uploadFileInfo : _remoteRootFileInfo;
|
||||||
|
|
||||||
|
auto newRequest = request;
|
||||||
|
newRequest.setRawHeader("X-Request-ID", OCC::AccessManager::generateRequestId());
|
||||||
auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute);
|
auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute);
|
||||||
FakeReply *reply = nullptr;
|
FakeReply *reply = nullptr;
|
||||||
if (verb == QLatin1String("PROPFIND"))
|
if (verb == QLatin1String("PROPFIND"))
|
||||||
// Ignore outgoingData always returning somethign good enough, works for now.
|
// Ignore outgoingData always returning somethign good enough, works for now.
|
||||||
reply = new FakePropfindReply { info, op, request, this };
|
reply = new FakePropfindReply { info, op, newRequest, this };
|
||||||
else if (verb == QLatin1String("GET") || op == QNetworkAccessManager::GetOperation)
|
else if (verb == QLatin1String("GET") || op == QNetworkAccessManager::GetOperation)
|
||||||
reply = new FakeGetReply { info, op, request, this };
|
reply = new FakeGetReply { info, op, newRequest, this };
|
||||||
else if (verb == QLatin1String("PUT") || op == QNetworkAccessManager::PutOperation)
|
else if (verb == QLatin1String("PUT") || op == QNetworkAccessManager::PutOperation)
|
||||||
reply = new FakePutReply { info, op, request, outgoingData->readAll(), this };
|
reply = new FakePutReply { info, op, newRequest, outgoingData->readAll(), this };
|
||||||
else if (verb == QLatin1String("MKCOL"))
|
else if (verb == QLatin1String("MKCOL"))
|
||||||
reply = new FakeMkcolReply { info, op, request, this };
|
reply = new FakeMkcolReply { info, op, newRequest, this };
|
||||||
else if (verb == QLatin1String("DELETE") || op == QNetworkAccessManager::DeleteOperation)
|
else if (verb == QLatin1String("DELETE") || op == QNetworkAccessManager::DeleteOperation)
|
||||||
reply = new FakeDeleteReply { info, op, request, this };
|
reply = new FakeDeleteReply { info, op, newRequest, this };
|
||||||
else if (verb == QLatin1String("MOVE") && !isUpload)
|
else if (verb == QLatin1String("MOVE") && !isUpload)
|
||||||
reply = new FakeMoveReply { info, op, request, this };
|
reply = new FakeMoveReply { info, op, newRequest, this };
|
||||||
else if (verb == QLatin1String("MOVE") && isUpload)
|
else if (verb == QLatin1String("MOVE") && isUpload)
|
||||||
reply = new FakeChunkMoveReply { info, _remoteRootFileInfo, op, request, this };
|
reply = new FakeChunkMoveReply { info, _remoteRootFileInfo, op, newRequest, this };
|
||||||
else {
|
else {
|
||||||
qDebug() << verb << outgoingData;
|
qDebug() << verb << outgoingData;
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
OCC::HttpLogger::logRequest(reply, op, outgoingData);
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue