Skip to content

Commit 9c4aedb

Browse files
committed
chore: make the permissions reading compatible with windows API
Signed-off-by: Matthieu Gallien <[email protected]>
1 parent 410709a commit 9c4aedb

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/csync/vio/csync_vio_local.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#ifndef _CSYNC_VIO_LOCAL_H
1010
#define _CSYNC_VIO_LOCAL_H
1111

12+
#include "csync.h"
13+
#include "ocsynclib.h"
14+
1215
#include <QString>
1316

1417
struct csync_vio_handle_t;

src/csync/vio/csync_vio_local_win.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ static time_t FileTimeToUnixTime(FILETIME *filetime, DWORD *remainder)
101101
}
102102
}
103103

104-
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs) {
104+
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs, bool checkPermissionsValidity)
105+
{
106+
Q_UNUSED(checkPermissionsValidity)
105107

106108
std::unique_ptr<csync_file_stat_t> file_stat;
107109
DWORD rem = 0;
@@ -125,7 +127,7 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h
125127
}
126128
auto path = QString::fromWCharArray(handle->ffd.cFileName);
127129
if (path == QLatin1String(".") || path == QLatin1String(".."))
128-
return csync_vio_local_readdir(handle, vfs);
130+
return csync_vio_local_readdir(handle, vfs, true);
129131

130132
file_stat = std::make_unique<csync_file_stat_t>();
131133
file_stat->path = path.toUtf8();
@@ -170,16 +172,18 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h
170172

171173
// path always ends with '\', by construction
172174

173-
if (csync_vio_local_stat(handle->path + QString::fromWCharArray(handle->ffd.cFileName), file_stat.get()) < 0) {
175+
if (csync_vio_local_stat(handle->path + QString::fromWCharArray(handle->ffd.cFileName), file_stat.get(), true) < 0) {
174176
// Will get excluded by _csync_detect_update.
175177
file_stat->type = ItemTypeSkip;
176178
}
177179

178180
return file_stat;
179181
}
180182

181-
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf)
183+
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf, bool checkPermissionsValidity)
182184
{
185+
Q_UNUSED(checkPermissionsValidity)
186+
183187
/* Almost nothing to do since csync_vio_local_readdir already filled up most of the information
184188
But we still need to fetch the file ID.
185189
Possible optimisation: only fetch the file id when we need it (for new files)

src/libsync/filesystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static qint64 getSizeWithCsync(const QString &filename)
231231
{
232232
qint64 result = 0;
233233
csync_file_stat_t stat;
234-
if (csync_vio_local_stat(filename, &stat) != -1) {
234+
if (csync_vio_local_stat(filename, &stat, true) != -1) {
235235
result = stat.size;
236236
} else {
237237
qCWarning(lcFileSystem) << "Could not get size for" << filename << "with csync" << Utility::formatWinError(errno);

0 commit comments

Comments
 (0)