diff options
-rw-r--r-- | docs/modules/ROOT/pages/troubleshooting.adoc | 20 | ||||
-rw-r--r-- | src/common/filesystembase.cpp | 16 | ||||
-rw-r--r-- | src/common/utility.cpp | 3 | ||||
-rw-r--r-- | src/libsync/owncloudpropagator.cpp | 4 | ||||
-rw-r--r-- | test/testlockedfiles.cpp | 20 |
5 files changed, 42 insertions, 21 deletions
diff --git a/docs/modules/ROOT/pages/troubleshooting.adoc b/docs/modules/ROOT/pages/troubleshooting.adoc index 3e1463dc8..23e9fe6d3 100644 --- a/docs/modules/ROOT/pages/troubleshooting.adoc +++ b/docs/modules/ROOT/pages/troubleshooting.adoc @@ -118,6 +118,26 @@ owncloud --logdir /tmp/owncloud_logs --logexpire 48 Adding the `--logdebug` flag increases the verbosity of the generated log files. +==== Logging in the Console + +If the ownCloud client isn't able to start and immediately crashes the first two options are not available. +Therefore it might need to be necessary to start the ownCloud client using the command line in order to be see the error message + +On Linux and Mac simply open the terminal and run: +``` +owncloud --logfile - --logflush +``` + +On Windows open a PowerShell and run the following command: + +``` +& 'C:\Program Files\ownCloud\owncloud.exe' --logfile - --logflush | Write-Host +``` + +Make sure to copy the whole command and adjust the path to your `owncloud.exe`, if you have chosen to install the client in a different path. + +To further increase the verbosity of the output you can also combine these commands with the `--logdebug` argument. + ==== Control Log Content Thanks to the Qt framework, logging can be controlled at run-time through the `QT_LOGGING_RULES` environment variable. diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index 733b75f76..e1b7facee 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -205,14 +205,8 @@ bool FileSystem::uncheckedRenameReplace(const QString &originFileName, (wchar_t *)dest.utf16(), MOVEFILE_REPLACE_EXISTING + MOVEFILE_COPY_ALLOWED + MOVEFILE_WRITE_THROUGH); if (!ok) { - wchar_t *string = 0; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&string, 0, NULL); - - *errorString = QString::fromWCharArray(string); + *errorString = Utility::formatWinError(GetLastError()); qCWarning(lcFileSystem) << "Renaming temp file to final failed: " << *errorString; - LocalFree((HLOCAL)string); return false; } #endif @@ -449,13 +443,13 @@ bool FileSystem::moveToTrash(const QString &fileName, QString *errorString) bool FileSystem::isFileLocked(const QString &fileName) { #ifdef Q_OS_WIN - const wchar_t *wuri = reinterpret_cast<const wchar_t *>(fileName.utf16()); // Check if file exists - DWORD attr = GetFileAttributesW(wuri); + const QString fName = longWinPath(fileName); + DWORD attr = GetFileAttributesW(reinterpret_cast<const wchar_t *>(fName.utf16())); if (attr != INVALID_FILE_ATTRIBUTES) { // Try to open the file with as much access as possible.. HANDLE win_h = CreateFileW( - wuri, + reinterpret_cast<const wchar_t *>(fName.utf16()), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, @@ -485,7 +479,7 @@ bool FileSystem::isJunction(const QString &filename) { #ifdef Q_OS_WIN WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFileEx((const wchar_t *)filename.utf16(), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0); + HANDLE hFind = FindFirstFileEx(reinterpret_cast<const wchar_t *>(longWinPath(filename).utf16()), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0); if (hFind != INVALID_HANDLE_VALUE) { FindClose(hFind); return false; diff --git a/src/common/utility.cpp b/src/common/utility.cpp index d0dc3d018..b800c7ef8 100644 --- a/src/common/utility.cpp +++ b/src/common/utility.cpp @@ -19,6 +19,7 @@ #include "config.h" #include "common/utility.h" +#include "common/filesystembase.h" #include "version.h" // Note: This file must compile without QtGui @@ -222,7 +223,7 @@ qint64 Utility::freeDiskSpace(const QString &path) #elif defined(Q_OS_WIN) ULARGE_INTEGER freeBytes; freeBytes.QuadPart = 0L; - if (GetDiskFreeSpaceEx(reinterpret_cast<const wchar_t *>(path.utf16()), &freeBytes, NULL, NULL)) { + if (GetDiskFreeSpaceEx(reinterpret_cast<const wchar_t *>(FileSystem::longWinPath(path).utf16()), &freeBytes, NULL, NULL)) { return freeBytes.QuadPart; } #endif diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index b349a4d9f..87dbbde16 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -534,7 +534,7 @@ bool OwncloudPropagator::localFileNameClash(const QString &relFile) WIN32_FIND_DATA FindFileData; HANDLE hFind; - hFind = FindFirstFileW((wchar_t *)file.utf16(), &FindFileData); + hFind = FindFirstFileW(reinterpret_cast<const wchar_t *>(FileSystem::longWinPath(file).utf16()), &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { // returns false. } else { @@ -568,7 +568,7 @@ bool OwncloudPropagator::hasCaseClashAccessibilityProblem(const QString &relfile WIN32_FIND_DATA FindFileData; HANDLE hFind; - hFind = FindFirstFileW(reinterpret_cast<const wchar_t *>(file.utf16()), &FindFileData); + hFind = FindFirstFileW(reinterpret_cast<const wchar_t *>(FileSystem::longWinPath(file).utf16()), &FindFileData); if (hFind != INVALID_HANDLE_VALUE) { QString firstFile = QString::fromWCharArray(FindFileData.cFileName); if (FindNextFile(hFind, &FindFileData)) { diff --git a/test/testlockedfiles.cpp b/test/testlockedfiles.cpp index df1e8f8d0..cae7fb11c 100644 --- a/test/testlockedfiles.cpp +++ b/test/testlockedfiles.cpp @@ -17,7 +17,8 @@ using namespace OCC; // pass combination of FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_DELETE HANDLE makeHandle(const QString &file, int shareMode) { - const wchar_t *wuri = reinterpret_cast<const wchar_t *>(file.utf16()); + const auto fName = FileSystem::longWinPath(file); + const wchar_t *wuri = reinterpret_cast<const wchar_t *>(fName.utf16()); auto handle = CreateFileW( wuri, GENERIC_READ | GENERIC_WRITE, @@ -39,6 +40,7 @@ class TestLockedFiles : public QObject private slots: void testBasicLockFileWatcher() { + QTemporaryDir tmp; int count = 0; QString file; @@ -46,12 +48,16 @@ private slots: watcher.setCheckInterval(std::chrono::milliseconds(50)); connect(&watcher, &LockWatcher::fileUnlocked, &watcher, [&](const QString &f) { ++count; file = f; }); - QString tmpFile; + const QString tmpFile = tmp.path() + QString::fromUtf8("/alonglonglonglong/blonglonglonglong/clonglonglonglong/dlonglonglonglong/" + "elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/" + "jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/" + "olonglonglonglong/file🐷.txt"); { - QTemporaryFile tmp; - tmp.setAutoRemove(false); - tmp.open(); - tmpFile = tmp.fileName(); + // use a long file path to ensure we handle that correctly + QVERIFY(QFileInfo(tmpFile).dir().mkpath(".")); + QFile tmp(tmpFile); + QVERIFY(tmp.open(QFile::WriteOnly)); + QVERIFY(tmp.write("ownCLoud")); } QVERIFY(QFile::exists(tmpFile)); @@ -91,7 +97,7 @@ private slots: QCOMPARE(file, tmpFile); QVERIFY(!watcher.contains(tmpFile)); #endif - QFile::remove(tmpFile); + QVERIFY(tmp.remove()); } #ifdef Q_OS_WIN |