mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Add time difference check to the init function.
This commit is contained in:
parent
20da2351cf
commit
c318daed7f
15
src/csync.c
15
src/csync.c
@ -34,6 +34,7 @@
|
||||
#include "csync_exclude.h"
|
||||
#include "csync_lock.h"
|
||||
#include "csync_journal.h"
|
||||
#include "csync_time.h"
|
||||
#include "csync_util.h"
|
||||
|
||||
#include "csync_update.h"
|
||||
@ -119,6 +120,7 @@ int csync_create(CSYNC **csync, const char *local, const char *remote) {
|
||||
|
||||
int csync_init(CSYNC *ctx) {
|
||||
int rc;
|
||||
time_t timediff = -1;
|
||||
char *log = NULL;
|
||||
char *exclude = NULL;
|
||||
char *journal = NULL;
|
||||
@ -241,6 +243,19 @@ int csync_init(CSYNC *ctx) {
|
||||
ctx->remote.type = LOCAL_REPLICA;
|
||||
}
|
||||
|
||||
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);
|
||||
rc = -1;
|
||||
goto out;
|
||||
} else if (timediff < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "Synchronisation is not possible!");
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (c_rbtree_create(&ctx->local.tree, key_cmp, data_cmp) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
|
||||
@ -8,11 +8,15 @@
|
||||
CSYNC *csync;
|
||||
|
||||
static void setup(void) {
|
||||
system("mkdir -p /tmp/csync1");
|
||||
system("mkdir -p /tmp/csync2");
|
||||
csync_create(&csync, "/tmp/csync1", "/tmp/csync2");
|
||||
}
|
||||
|
||||
static void teardown(void) {
|
||||
csync_destroy(csync);
|
||||
system("rm -rf /tmp/csync1");
|
||||
system("rm -rf /tmp/csync2");
|
||||
}
|
||||
|
||||
START_TEST (check_csync_destroy_null)
|
||||
@ -60,6 +64,9 @@ int main(void) {
|
||||
|
||||
SRunner *sr;
|
||||
sr = srunner_create(s);
|
||||
#if 0
|
||||
srunner_set_fork_status(sr, CK_NOFORK);
|
||||
#endif
|
||||
srunner_run_all(sr, CK_VERBOSE);
|
||||
nf = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user