зеркало из https://github.com/nextcloud/desktop.git
csync: Remove time_sync_required
This commit is contained in:
Родитель
869793592d
Коммит
eff2427a03
|
@ -225,25 +225,6 @@ retry_vio_init:
|
|||
}
|
||||
|
||||
if(!ctx->options.local_only_mode) {
|
||||
if(ctx->module.capabilities.time_sync_required) {
|
||||
timediff = csync_timediff(ctx);
|
||||
if (timediff > ctx->options.max_time_difference) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL,
|
||||
"Clock skew detected. The time difference is greater than %d seconds!",
|
||||
ctx->options.max_time_difference);
|
||||
ctx->status_code = CSYNC_STATUS_TIMESKEW;
|
||||
rc = -1;
|
||||
goto out;
|
||||
} else if (timediff < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "Synchronisation is not possible!");
|
||||
ctx->status_code = CSYNC_STATUS_TIMESKEW;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Module does not need time synchronization.");
|
||||
}
|
||||
|
||||
if(ctx->module.capabilities.unix_extensions == -1) { /* detect */
|
||||
if (csync_unix_extensions(ctx) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "Could not detect filesystem type.");
|
||||
|
|
|
@ -894,11 +894,10 @@ static int owncloud_stat(const char *uri, csync_vio_file_stat_t *buf) {
|
|||
/* capabilities are currently:
|
||||
* bool atomar_copy_support - oC provides atomar copy
|
||||
* bool do_post_copy_stat - oC does not want the post copy check
|
||||
* bool time_sync_required - oC does not require the time sync
|
||||
* int unix_extensions - oC supports unix extensions.
|
||||
* bool propagate_on_fd - oC supports the send_file method.
|
||||
*/
|
||||
static csync_vio_capabilities_t _owncloud_capabilities = { true, false, false, 0, true, false, false };
|
||||
static csync_vio_capabilities_t _owncloud_capabilities = { true, false, 0, true, false, false };
|
||||
|
||||
static csync_vio_capabilities_t *owncloud_capabilities(void)
|
||||
{
|
||||
|
|
|
@ -62,115 +62,4 @@ int csync_gettime(struct timespec *tp)
|
|||
|
||||
#undef CSYNC_CLOCK
|
||||
|
||||
/* check time difference between the replicas */
|
||||
time_t csync_timediff(CSYNC *ctx) {
|
||||
time_t timediff = -1;
|
||||
char errbuf[256] = {0};
|
||||
char *luri = NULL;
|
||||
char *ruri = NULL;
|
||||
csync_vio_handle_t *fp = NULL;
|
||||
csync_vio_file_stat_t *st = NULL;
|
||||
csync_vio_handle_t *dp = NULL;
|
||||
|
||||
/* try to open remote dir to get auth */
|
||||
ctx->replica = ctx->remote.type;
|
||||
dp = csync_vio_opendir(ctx, ctx->remote.uri);
|
||||
if (dp == NULL) {
|
||||
/*
|
||||
* To prevent problems especially with pam_csync we shouldn't try to create the
|
||||
* remote directory here. Just fail!
|
||||
*/
|
||||
C_STRERROR(errno, errbuf, sizeof(errbuf));
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL,
|
||||
"Access dienied to remote uri: %s - %s",
|
||||
ctx->remote.uri,
|
||||
errbuf);
|
||||
ctx->status_code = CSYNC_STATUS_REMOTE_ACCESS_ERROR;
|
||||
return -1;
|
||||
}
|
||||
csync_vio_closedir(ctx, dp);
|
||||
|
||||
if (asprintf(&luri, "%s/.csync_timediff.ctmp", ctx->local.uri) < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (asprintf(&ruri, "%s/.csync_timediff.ctmp", ctx->remote.uri) < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* create temporary file on local */
|
||||
ctx->replica = ctx->local.type;
|
||||
fp = csync_vio_creat(ctx, luri, 0644);
|
||||
if (fp == NULL) {
|
||||
C_STRERROR(errno, errbuf, sizeof(errbuf));
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL,
|
||||
"Unable to create temporary file: %s - %s",
|
||||
luri,
|
||||
errbuf);
|
||||
ctx->status_code = CSYNC_STATUS_LOCAL_CREATE_ERROR;
|
||||
goto out;
|
||||
}
|
||||
csync_vio_close(ctx, fp);
|
||||
|
||||
/* Get the modification time */
|
||||
st = csync_vio_file_stat_new();
|
||||
if (csync_vio_stat(ctx, luri, st) < 0) {
|
||||
C_STRERROR(errno, errbuf, sizeof(errbuf));
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL,
|
||||
"Synchronisation is not possible! %s - %s",
|
||||
luri,
|
||||
errbuf);
|
||||
ctx->status_code = CSYNC_STATUS_LOCAL_STAT_ERROR;
|
||||
goto out;
|
||||
}
|
||||
timediff = st->mtime;
|
||||
csync_vio_file_stat_destroy(st);
|
||||
st = NULL;
|
||||
|
||||
/* create temporary file on remote replica */
|
||||
ctx->replica = ctx->remote.type;
|
||||
|
||||
fp = csync_vio_creat(ctx, ruri, 0644);
|
||||
if (fp == NULL) {
|
||||
C_STRERROR(errno, errbuf, sizeof(errbuf));
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL,
|
||||
"Unable to create temporary file: %s - %s",
|
||||
ruri,
|
||||
errbuf);
|
||||
ctx->status_code = CSYNC_STATUS_REMOTE_CREATE_ERROR;
|
||||
goto out;
|
||||
}
|
||||
csync_vio_close(ctx, fp);
|
||||
|
||||
/* Get the modification time */
|
||||
st = csync_vio_file_stat_new();
|
||||
if (csync_vio_stat(ctx, ruri, st) < 0) {
|
||||
C_STRERROR(errno, errbuf, sizeof(errbuf));
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL,
|
||||
"Synchronisation is not possible! %s - %s",
|
||||
ruri,
|
||||
errbuf);
|
||||
ctx->status_code = CSYNC_STATUS_REMOTE_STAT_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* calc time difference */
|
||||
timediff = llabs(timediff - st->mtime);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Time difference: %ld seconds", timediff);
|
||||
|
||||
out:
|
||||
csync_vio_file_stat_destroy(st);
|
||||
|
||||
ctx->replica = ctx->local.type;
|
||||
csync_vio_unlink(ctx, luri);
|
||||
SAFE_FREE(luri);
|
||||
|
||||
ctx->replica = ctx->remote.type;
|
||||
csync_vio_unlink(ctx, ruri);
|
||||
SAFE_FREE(ruri);
|
||||
|
||||
return timediff;
|
||||
}
|
||||
|
||||
|
||||
/* vim: set ts=8 sw=2 et cindent: */
|
||||
|
|
|
@ -26,6 +26,5 @@
|
|||
#include "csync_private.h"
|
||||
|
||||
int csync_gettime(struct timespec *tp);
|
||||
time_t csync_timediff(CSYNC *ctx);
|
||||
|
||||
#endif /* _CSYNC_TIME_H */
|
||||
|
|
|
@ -73,7 +73,6 @@ int csync_vio_init(CSYNC *ctx, const char *module, const char *args) {
|
|||
/* Useful defaults to the module capabilities */
|
||||
ctx->module.capabilities.atomar_copy_support = false;
|
||||
ctx->module.capabilities.do_post_copy_stat = true;
|
||||
ctx->module.capabilities.time_sync_required = true;
|
||||
ctx->module.capabilities.unix_extensions = -1; /* detect automatically */
|
||||
ctx->module.capabilities.use_send_file_to_propagate = false; /* do use read/write by default */
|
||||
|
||||
|
@ -86,8 +85,6 @@ int csync_vio_init(CSYNC *ctx, const char *module, const char *args) {
|
|||
ctx->module.capabilities.atomar_copy_support ? "yes": "no");
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "capabilities: post copy stat: %s",
|
||||
ctx->module.capabilities.do_post_copy_stat ? "yes": "no");
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "capabilities: time sync required: %s",
|
||||
ctx->module.capabilities.time_sync_required ? "yes": "no");
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "capabilities: unix extensions: %d",
|
||||
ctx->module.capabilities.unix_extensions );
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "capabilities: use send_file: %s",
|
||||
|
|
|
@ -38,7 +38,6 @@ typedef struct csync_vio_method_s csync_vio_method_t;
|
|||
struct csync_vio_capabilities_s {
|
||||
bool atomar_copy_support; /* set to true if the backend provides atomar copy */
|
||||
bool do_post_copy_stat; /* true if csync should check the copy afterwards */
|
||||
bool time_sync_required; /* true if local and remote need to be time synced */
|
||||
int unix_extensions; /* -1: do csync detection, 0: no unix extensions,
|
||||
1: extensions available */
|
||||
bool use_send_file_to_propagate; /* if set, the module rather copies files using send_file than read and write */
|
||||
|
|
Загрузка…
Ссылка в новой задаче