diff --git a/csync/src/csync_private.h b/csync/src/csync_private.h index a28eb82100c..205fa17c6b7 100644 --- a/csync/src/csync_private.h +++ b/csync/src/csync_private.h @@ -89,7 +89,7 @@ struct csync_s { /* hooks for checking the white list (uses the update_callback_userdata) */ int (*checkSelectiveSyncBlackListHook)(void*, const char*); - int (*checkSelectiveSyncNewFolderHook)(void*, const char*); + int (*checkSelectiveSyncNewFolderHook)(void*, const char* /* path */, const char* /* remotePerm */); csync_vio_opendir_hook remote_opendir_hook; diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c index b5b34797195..fefc8080724 100644 --- a/csync/src/csync_update.c +++ b/csync/src/csync_update.c @@ -436,7 +436,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, st->instruction = CSYNC_INSTRUCTION_NEW; if (fs->type == CSYNC_VIO_FILE_TYPE_DIRECTORY && ctx->current == REMOTE_REPLICA && ctx->callbacks.checkSelectiveSyncNewFolderHook) { - if (ctx->callbacks.checkSelectiveSyncNewFolderHook(ctx->callbacks.update_callback_userdata, path)) { + if (ctx->callbacks.checkSelectiveSyncNewFolderHook(ctx->callbacks.update_callback_userdata, path, st->remotePerm)) { csync_file_stat_free(st); return 1; } diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index bb35f1f97f8..b629b426ed9 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -20,6 +20,9 @@ #include #include "account.h" #include +#include "theme.h" +#include + namespace OCC { @@ -81,13 +84,21 @@ int DiscoveryJob::isInSelectiveSyncBlackListCallback(void *data, const char *pat return static_cast(data)->isInSelectiveSyncBlackList(path); } -bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path) +bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path, const char *remotePerm) { // If this path or the parent is in the white list, then we do not block this file if (findPathInList(_selectiveSyncWhiteList, path)) { return false; } + if (Theme::instance()->dontSyncMountedStorageByDefault()) { + // 'M' in the permission means that it is unselected by default. (issue #5331) + if (std::strchr(remotePerm, 'M')) { + emit newBigFolder(path); + return true; + } + } + if (_newBigFolderSizeLimit < 0) { // no limit, everything is allowed; return false; @@ -119,9 +130,9 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path) } } -int DiscoveryJob::checkSelectiveSyncNewFolderCallback(void *data, const char *path) +int DiscoveryJob::checkSelectiveSyncNewFolderCallback(void *data, const char *path, const char *remotePerm) { - return static_cast(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path)); + return static_cast(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path), remotePerm); } diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index c030adb3339..701581c06df 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -176,8 +176,8 @@ class DiscoveryJob : public QObject { */ bool isInSelectiveSyncBlackList(const char* path) const; static int isInSelectiveSyncBlackListCallback(void *, const char *); - bool checkSelectiveSyncNewFolder(const QString &path); - static int checkSelectiveSyncNewFolderCallback(void*, const char*); + bool checkSelectiveSyncNewFolder(const QString &path, const char *remotePerm); + static int checkSelectiveSyncNewFolderCallback(void* data, const char* path, const char* remotePerm); // Just for progress static void update_job_update_callback (bool local, diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 53e850b9999..3a0c0b3edbb 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -478,4 +478,10 @@ QString Theme::quotaBaseFolder() const { return QLatin1String("/"); } + +bool Theme::dontSyncMountedStorageByDefault() const +{ + return false; +} + } // end namespace client diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 63c86b4aa1f..4e6130fd6da 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -302,6 +302,12 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject */ virtual QString quotaBaseFolder() const; + /** + * By default, mounted storage will not be sync'ed (i.e, they will be disabled in the + * selective sync + */ + virtual bool dontSyncMountedStorageByDefault() const; + protected: #ifndef TOKEN_AUTH_ONLY QIcon themeIcon(const QString& name, bool sysTray = false, bool sysTrayMenuVisible = false) const;