diff --git a/src/csync/vio/csync_vio_local.h b/src/csync/vio/csync_vio_local.h index 5ae05a5b3..769d1d020 100644 --- a/src/csync/vio/csync_vio_local.h +++ b/src/csync/vio/csync_vio_local.h @@ -22,10 +22,13 @@ #define _CSYNC_VIO_LOCAL_H struct csync_vio_handle_t; +namespace OCC { +class Vfs; +} csync_vio_handle_t OCSYNC_EXPORT *csync_vio_local_opendir(const QString &name); int OCSYNC_EXPORT csync_vio_local_closedir(csync_vio_handle_t *dhandle); -std::unique_ptr OCSYNC_EXPORT csync_vio_local_readdir(CSYNC *ctx, csync_vio_handle_t *dhandle); +std::unique_ptr OCSYNC_EXPORT csync_vio_local_readdir(csync_vio_handle_t *dhandle, OCC::Vfs *vfs); int OCSYNC_EXPORT csync_vio_local_stat(const char *uri, csync_file_stat_t *buf); diff --git a/src/csync/vio/csync_vio_local_unix.cpp b/src/csync/vio/csync_vio_local_unix.cpp index 9de6092fc..705d04252 100644 --- a/src/csync/vio/csync_vio_local_unix.cpp +++ b/src/csync/vio/csync_vio_local_unix.cpp @@ -35,7 +35,7 @@ #include "csync_util.h" #include "vio/csync_vio_local.h" -#include "common/vfsplugin.h" +#include "common/vfs.h" #include #include @@ -74,7 +74,7 @@ int csync_vio_local_closedir(csync_vio_handle_t *dhandle) { return rc; } -std::unique_ptr csync_vio_local_readdir(CSYNC *ctx, csync_vio_handle_t *handle) { +std::unique_ptr csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs) { struct _tdirent *dirent = NULL; std::unique_ptr file_stat; @@ -123,8 +123,8 @@ std::unique_ptr csync_vio_local_readdir(CSYNC *ctx, csync_vio } // Override type for virtual files if desired - if (ctx->vfs) - ctx->vfs->statTypeVirtualFile(file_stat.get(), nullptr); + if (vfs) + vfs->statTypeVirtualFile(file_stat.get(), nullptr); return file_stat; } diff --git a/src/csync/vio/csync_vio_local_win.cpp b/src/csync/vio/csync_vio_local_win.cpp index 5f094d280..8f0114767 100644 --- a/src/csync/vio/csync_vio_local_win.cpp +++ b/src/csync/vio/csync_vio_local_win.cpp @@ -115,7 +115,7 @@ static time_t FileTimeToUnixTime(FILETIME *filetime, DWORD *remainder) } } -std::unique_ptr csync_vio_local_readdir(CSYNC *ctx, csync_vio_handle_t *handle) { +std::unique_ptr csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs) { std::unique_ptr file_stat; DWORD rem; @@ -139,12 +139,12 @@ std::unique_ptr csync_vio_local_readdir(CSYNC *ctx, csync_vio } auto path = c_utf8_from_locale(handle->ffd.cFileName); if (path == "." || path == "..") - return csync_vio_local_readdir(ctx, handle); + return csync_vio_local_readdir(handle, vfs); file_stat = std::make_unique(); file_stat->path = path; - if (ctx->vfs && ctx->vfs->statTypeVirtualFile(file_stat.get(), &handle->ffd)) { + if (vfs && vfs->statTypeVirtualFile(file_stat.get(), &handle->ffd)) { // all good } else if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { // Detect symlinks, and treat junctions as symlinks too. diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 9ca95d07e..815318c09 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -394,7 +394,8 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( return; } // Turn new remote files into virtual files if the option is enabled. - if (!localEntry.isValid() && _discoveryData->_syncOptions._newFilesAreVirtual && item->_type == ItemTypeFile) { + auto vfs = _discoveryData->_syncOptions._vfs; + if (!localEntry.isValid() && vfs && vfs->mode() == Vfs::WithSuffix && item->_type == ItemTypeFile) { item->_type = ItemTypeVirtualFile; addVirtualFileSuffix(path._original); } @@ -1151,12 +1152,15 @@ void ProcessDirectoryJob::dbError() void ProcessDirectoryJob::addVirtualFileSuffix(QString &str) const { - str.append(_discoveryData->_syncOptions._virtualFileSuffix); + if (auto vfs = _discoveryData->_syncOptions._vfs) + str.append(vfs->fileSuffix()); } bool ProcessDirectoryJob::hasVirtualFileSuffix(const QString &str) const { - return str.endsWith(_discoveryData->_syncOptions._virtualFileSuffix); + if (auto vfs = _discoveryData->_syncOptions._vfs) + return str.endsWith(vfs->fileSuffix()); + return false; } void ProcessDirectoryJob::chopVirtualFileSuffix(QString &str) const @@ -1164,7 +1168,7 @@ void ProcessDirectoryJob::chopVirtualFileSuffix(QString &str) const bool hasSuffix = hasVirtualFileSuffix(str); ASSERT(hasSuffix); if (hasSuffix) - str.chop(_discoveryData->_syncOptions._virtualFileSuffix.size()); + str.chop(_discoveryData->_syncOptions._vfs->fileSuffix().size()); } DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery() @@ -1246,7 +1250,7 @@ bool ProcessDirectoryJob::runLocalQuery() return false; } errno = 0; - while (auto dirent = csync_vio_local_readdir(dh)) { + while (auto dirent = csync_vio_local_readdir(dh, _discoveryData->_syncOptions._vfs)) { if (dirent->type == ItemTypeSkip) continue; LocalInfo i; diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp index 5d07ed20a..1f541adc0 100644 --- a/test/csync/vio_tests/check_vio_ext.cpp +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -196,7 +196,8 @@ static void traverse_dir(void **state, const char *dir, int *cnt) dh = csync_vio_local_opendir(dir); assert_non_null(dh); - while( (dirent = csync_vio_local_readdir(dh)) ) { + OCC::Vfs *vfs = nullptr; + while( (dirent = csync_vio_local_readdir(dh, vfs)) ) { assert_non_null(dirent.get()); if (!dirent->original_path.isEmpty()) { sv->ignored_dir = c_strdup(dirent->original_path);