Skip to content

Commit

Permalink
Discovery: Add branding option to disable default sync of 'M' directo…
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart authored and guruz committed Jan 27, 2017
1 parent d75b838 commit 70da607
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion csync/src/csync_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion csync/src/csync_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, fs->remotePerm)) {
csync_file_stat_free(st);
return 1;
}
Expand Down
17 changes: 14 additions & 3 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <QUrl>
#include "account.h"
#include <QFileInfo>
#include "theme.h"
#include <cstring>


namespace OCC {

Expand Down Expand Up @@ -81,13 +84,21 @@ int DiscoveryJob::isInSelectiveSyncBlackListCallback(void *data, const char *pat
return static_cast<DiscoveryJob*>(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;
Expand Down Expand Up @@ -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<DiscoveryJob*>(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path));
return static_cast<DiscoveryJob*>(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path), remotePerm);
}


Expand Down
4 changes: 2 additions & 2 deletions src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,10 @@ QString Theme::quotaBaseFolder() const
{
return QLatin1String("/");
}

bool Theme::dontSyncMountedStorageByDefault() const
{
return false;
}

} // end namespace client
6 changes: 6 additions & 0 deletions src/libsync/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 70da607

Please sign in to comment.