mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 11:48:56 +03:00
Add a check if we are operating remote on a unix filesystem.
This extends the exclude function. Maybe we should do this for the local too.
This commit is contained in:
parent
e86225db0e
commit
e0807cba1b
5 changed files with 64 additions and 0 deletions
|
@ -112,6 +112,7 @@ int csync_create(CSYNC **csync, const char *local, const char *remote) {
|
|||
|
||||
ctx->options.max_depth = MAX_DEPTH;
|
||||
ctx->options.max_time_difference = MAX_TIME_DIFFERENCE;
|
||||
ctx->options.unix_filesystem = 0;
|
||||
|
||||
ctx->pwd.uid = getuid();
|
||||
ctx->pwd.euid = geteuid();
|
||||
|
@ -274,6 +275,12 @@ int csync_init(CSYNC *ctx) {
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (csync_unix_filesystem(ctx) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "Could not detect filesystem type.");
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (c_rbtree_create(&ctx->local.tree, _key_cmp, _data_cmp) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
|
|
|
@ -105,6 +105,26 @@ void csync_exclude_destroy(CSYNC *ctx) {
|
|||
|
||||
int csync_excluded(CSYNC *ctx, const char *path) {
|
||||
size_t i;
|
||||
const char *p;
|
||||
|
||||
if (! ctx->options.unix_filesystem) {
|
||||
for (p = path; *p; p++) {
|
||||
switch (*p) {
|
||||
case '/':
|
||||
case '\\':
|
||||
case ':':
|
||||
case '?':
|
||||
case '*':
|
||||
case '"':
|
||||
case '>':
|
||||
case '<':
|
||||
case '|':
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->excludes == NULL) {
|
||||
return 0;
|
||||
|
|
|
@ -109,6 +109,7 @@ struct csync_s {
|
|||
int max_depth;
|
||||
int max_time_difference;
|
||||
int sync_symbolic_links;
|
||||
int unix_filesystem;
|
||||
char *config_dir;
|
||||
} options;
|
||||
|
||||
|
|
|
@ -253,3 +253,37 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
int csync_unix_filesystem(CSYNC *ctx) {
|
||||
int rc = -1;
|
||||
char *uri = NULL;
|
||||
csync_vio_handle_t *fp = NULL;
|
||||
|
||||
ctx->options.unix_filesystem = 0;
|
||||
|
||||
if (asprintf(&uri, "%s/csync_file*test.ctmp", ctx->remote.uri) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ctx->replica = ctx->remote.type;
|
||||
fp = csync_vio_creat(ctx, uri, 0644);
|
||||
if (fp == NULL) {
|
||||
rc = 0;
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO,
|
||||
"Disabled unix filesystem synchronization");
|
||||
goto out;
|
||||
}
|
||||
csync_vio_close(ctx, fp);
|
||||
|
||||
ctx->options.unix_filesystem = 1;
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO, "Enabled unix filesystem synchronization");
|
||||
|
||||
rc = 1;
|
||||
|
||||
out:
|
||||
csync_vio_unlink(ctx, uri);
|
||||
SAFE_FREE(uri);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,4 +31,6 @@ void csync_memstat_check(void);
|
|||
|
||||
int csync_merge_file_trees(CSYNC *ctx);
|
||||
|
||||
int csync_unix_filesystem(CSYNC *ctx);
|
||||
|
||||
#endif /* _CSYNC_UTIL_H */
|
||||
|
|
Loading…
Reference in a new issue