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

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/csync
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-02-12 15:06:13 +0300
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>2021-08-23 10:40:27 +0300
commit789e0e45d5887e116b08cc1848b767f36a9fe228 (patch)
tree60df5c66707e716c9254c48d00ac2f2ffc93ba60 /src/csync
parent56364f1c700fd2e63888fdd801a928771f765d91 (diff)
Fix Windows long path issue introduced in dd641fae997d71c8396b77def2fa25ad96fdf47f
Diffstat (limited to 'src/csync')
-rw-r--r--src/csync/vio/csync_vio_local_win.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/csync/vio/csync_vio_local_win.cpp b/src/csync/vio/csync_vio_local_win.cpp
index 7aa07f4da..4ddd4f545 100644
--- a/src/csync/vio/csync_vio_local_win.cpp
+++ b/src/csync/vio/csync_vio_local_win.cpp
@@ -34,6 +34,7 @@
#include "csync.h"
#include "vio/csync_vio_local.h"
#include "common/filesystembase.h"
+#include "common/utility.h"
#include <QtCore/QLoggingCategory>
@@ -52,8 +53,6 @@ struct csync_vio_handle_t {
QString path; // Always ends with '\'
};
-static int _csync_vio_local_stat_mb(const QString &path, csync_file_stat_t *buf);
-
csync_vio_handle_t *csync_vio_local_opendir(const QString &name) {
QScopedPointer<csync_vio_handle_t> handle(new csync_vio_handle_t{});
@@ -175,12 +174,9 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h
file_stat->size = (handle->ffd.nFileSizeHigh * ((int64_t)(MAXDWORD)+1)) + handle->ffd.nFileSizeLow;
file_stat->modtime = FileTimeToUnixTime(&handle->ffd.ftLastWriteTime, &rem);
- QString fullPath;
- fullPath.reserve(handle->path.size() + std::wcslen(handle->ffd.cFileName));
- fullPath += handle->path; // path always ends with '\', by construction
- fullPath += QString::fromWCharArray(handle->ffd.cFileName);
+ // path always ends with '\', by construction
- if (_csync_vio_local_stat_mb(fullPath, file_stat.get()) < 0) {
+ if (csync_vio_local_stat(handle->path + QString::fromWCharArray(handle->ffd.cFileName), file_stat.get()) < 0) {
// Will get excluded by _csync_detect_update.
file_stat->type = ItemTypeSkip;
}
@@ -188,15 +184,8 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h
return file_stat;
}
-
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf)
{
- int rc = _csync_vio_local_stat_mb(uri, buf);
- return rc;
-}
-
-static int _csync_vio_local_stat_mb(const QString &path, csync_file_stat_t *buf)
-{
/* Almost nothing to do since csync_vio_local_readdir already filled up most of the information
But we still need to fetch the file ID.
Possible optimisation: only fetch the file id when we need it (for new files)
@@ -206,21 +195,19 @@ static int _csync_vio_local_stat_mb(const QString &path, csync_file_stat_t *buf)
BY_HANDLE_FILE_INFORMATION fileInfo;
ULARGE_INTEGER FileIndex;
- const auto longPath = OCC::FileSystem::longWinPath(path);
-
- h = CreateFileW(longPath.toStdWString().data(), 0, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
- nullptr, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
- nullptr );
+ h = CreateFileW(reinterpret_cast<const wchar_t *>(OCC::FileSystem::longWinPath(uri).utf16()), 0, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
+ NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
+ NULL);
if( h == INVALID_HANDLE_VALUE ) {
- qCCritical(lcCSyncVIOLocal) << "CreateFileW failed on" << longPath;
errno = GetLastError();
+ qCCritical(lcCSyncVIOLocal) << "CreateFileW failed on" << uri << OCC::Utility::formatWinError(errno);
return -1;
}
if(!GetFileInformationByHandle( h, &fileInfo ) ) {
- qCCritical(lcCSyncVIOLocal) << "GetFileInformationByHandle failed on" << longPath;
errno = GetLastError();
+ qCCritical(lcCSyncVIOLocal) << "GetFileInformationByHandle failed on" << uri << OCC::Utility::formatWinError(errno);
CloseHandle(h);
return -1;
}