зеркало из https://github.com/nextcloud/desktop.git
Merge remote-tracking branch 'freitag/dav' into ocsync
Conflicts: src/csync_propagate.c src/csync_statedb.c
This commit is contained in:
Коммит
4cc1ef3624
|
@ -25,7 +25,6 @@ include(DefineCMakeDefaults)
|
|||
include(DefinePlatformDefaults)
|
||||
include(DefineCompilerFlags)
|
||||
include(DefineOptions.cmake)
|
||||
include(CPackConfig.cmake)
|
||||
|
||||
include(DefineInstallationPaths)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
ChangeLog
|
||||
==========
|
||||
version 0.81.0 (released 2013-08-08, ownCloud Client 1.4beta1 )
|
||||
version 0.90.0 (released 2013-09-04, ownCloud Client 1.4)
|
||||
* Added API to get progress information from csync.
|
||||
* Added c_rename function to csync std.
|
||||
* Fix: Do renames of files before any puts.
|
||||
|
@ -18,8 +18,9 @@ version 0.81.0 (released 2013-08-08, ownCloud Client 1.4beta1 )
|
|||
* Left excluded files and links in csync's tree to be able to show.
|
||||
them to the user.
|
||||
* Add OC-Total-Length header for better quota handling.
|
||||
* Report inbetween progress
|
||||
|
||||
version 0.80.0 (released 2013 *06 *25)
|
||||
version 0.80.0 (released 2013-06-25)
|
||||
* Big file chunking (e.g. up/download of big files should now be no
|
||||
problem anymore)
|
||||
* Resuming (download of big files will resume)
|
||||
|
|
|
@ -822,6 +822,8 @@ static void _csync_clean_ctx(CSYNC *ctx)
|
|||
ctx->local.list = 0;
|
||||
ctx->remote.ignored_cleanup = 0;
|
||||
ctx->local.ignored_cleanup = 0;
|
||||
|
||||
SAFE_FREE(ctx->statedb.file);
|
||||
}
|
||||
|
||||
int csync_commit(CSYNC *ctx) {
|
||||
|
@ -913,7 +915,6 @@ int csync_destroy(CSYNC *ctx) {
|
|||
SAFE_FREE(ctx->local.uri);
|
||||
SAFE_FREE(ctx->remote.uri);
|
||||
SAFE_FREE(ctx->options.config_dir);
|
||||
SAFE_FREE(ctx->statedb.file);
|
||||
SAFE_FREE(ctx->error_string);
|
||||
|
||||
#ifdef WITH_ICONV
|
||||
|
|
|
@ -138,18 +138,18 @@ void csync_exclude_destroy(CSYNC *ctx) {
|
|||
c_strlist_destroy(ctx->excludes);
|
||||
}
|
||||
|
||||
int csync_excluded(CSYNC *ctx, const char *path) {
|
||||
CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path) {
|
||||
size_t i;
|
||||
const char *p;
|
||||
char *bname;
|
||||
int rc;
|
||||
int match = 0;
|
||||
CSYNC_EXCLUDE_TYPE match = CSYNC_NOT_EXCLUDED;
|
||||
CSYNC_EXCLUDE_TYPE type = CSYNC_NOT_EXCLUDED;
|
||||
const char *it;
|
||||
int type = 0;
|
||||
|
||||
/* exclude the lock file */
|
||||
if (c_streq( path, CSYNC_LOCK_FILE )) {
|
||||
return 1;
|
||||
return CSYNC_FILE_SILENTLY_EXCLUDED;
|
||||
}
|
||||
|
||||
if (! ctx->options.unix_extensions) {
|
||||
|
@ -163,26 +163,21 @@ int csync_excluded(CSYNC *ctx, const char *path) {
|
|||
case '>':
|
||||
case '<':
|
||||
case '|':
|
||||
return 1;
|
||||
return CSYNC_FILE_EXCLUDE_INVALID_CHAR;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rc = csync_fnmatch(".csync_journal.db*", path, 0);
|
||||
if (rc == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bname = c_basename(path);
|
||||
if (bname == NULL) {
|
||||
return 0;
|
||||
return CSYNC_NOT_EXCLUDED;
|
||||
}
|
||||
|
||||
rc = csync_fnmatch(".csync_journal.db*", bname, 0);
|
||||
if (rc == 0) {
|
||||
match = 1;
|
||||
match = CSYNC_FILE_SILENTLY_EXCLUDED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -190,13 +185,13 @@ int csync_excluded(CSYNC *ctx, const char *path) {
|
|||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; match == 0 && i < ctx->excludes->count; i++) {
|
||||
for (i = 0; match == CSYNC_NOT_EXCLUDED && i < ctx->excludes->count; i++) {
|
||||
it = ctx->excludes->vector[i];
|
||||
type = 1;
|
||||
type = CSYNC_FILE_EXCLUDE_LIST;
|
||||
/* Ecludes starting with ']' means it can be cleanup */
|
||||
if (it[0] == ']') {
|
||||
++it;
|
||||
type = 2;
|
||||
type = CSYNC_FILE_EXCLUDE_AND_REMOVE;
|
||||
}
|
||||
|
||||
rc = csync_fnmatch(it, path, 0);
|
||||
|
|
|
@ -21,6 +21,14 @@
|
|||
#ifndef _CSYNC_EXCLUDE_H
|
||||
#define _CSYNC_EXCLUDE_H
|
||||
|
||||
enum csync_exclude_type_e {
|
||||
CSYNC_NOT_EXCLUDED = 0,
|
||||
CSYNC_FILE_SILENTLY_EXCLUDED,
|
||||
CSYNC_FILE_EXCLUDE_AND_REMOVE,
|
||||
CSYNC_FILE_EXCLUDE_LIST,
|
||||
CSYNC_FILE_EXCLUDE_INVALID_CHAR
|
||||
};
|
||||
typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE;
|
||||
/**
|
||||
* @brief Load exclude list
|
||||
*
|
||||
|
@ -55,7 +63,7 @@ void csync_exclude_destroy(CSYNC *ctx);
|
|||
*
|
||||
* @return 2 if excluded and needs cleanup, 1 if excluded, 0 if not.
|
||||
*/
|
||||
int csync_excluded(CSYNC *ctx, const char *path);
|
||||
CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path);
|
||||
|
||||
#endif /* _CSYNC_EXCLUDE_H */
|
||||
|
||||
|
|
|
@ -311,8 +311,10 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
st->size != vst->size) {
|
||||
/* The size or modtime has changed. Skip this file copy for now. */
|
||||
rc = 1; /* soft problem */
|
||||
SAFE_FREE(st->error_string);
|
||||
st->error_string = c_strdup("File was updated meantime, publish next time.");
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
|
||||
"Source file has changed since update run, SKIP it for now.");
|
||||
"Source file %s has changed since update run, SKIP it for now.", suri);
|
||||
goto out;
|
||||
}
|
||||
csync_vio_file_stat_destroy(vst);
|
||||
|
@ -854,7 +856,7 @@ static int _backup_path(char** duri, const char* uri, const char* path)
|
|||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"extension: %s",info->extension);
|
||||
|
||||
if (asprintf(duri, "%s/%s%s_conflict-%s%s", uri,info->directory ,
|
||||
info->filename,timestring,info->extension) < 0) {
|
||||
info->filename, timestring, info->extension) < 0) {
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
|
@ -877,47 +879,38 @@ static int _csync_backup_file(CSYNC *ctx, csync_file_stat_t *st, char **duri) {
|
|||
|
||||
if(st->instruction==CSYNC_INSTRUCTION_CONFLICT)
|
||||
{
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"CSYNC_INSTRUCTION_CONFLICT");
|
||||
switch (ctx->current) {
|
||||
case LOCAL_REPLICA:
|
||||
drep = ctx->remote.type;
|
||||
if (asprintf(&suri, "%s/%s", ctx->remote.uri, st->path) < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"CSYNC_INSTRUCTION_CONFLICT");
|
||||
switch (ctx->current) {
|
||||
case LOCAL_REPLICA:
|
||||
drep = ctx->remote.type;
|
||||
if (asprintf(&suri, "%s/%s", ctx->remote.uri, st->path) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (_backup_path(duri, ctx->remote.uri,st->path) < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case REMOTE_REPLICA:
|
||||
drep = ctx->local.type;
|
||||
if (asprintf(&suri, "%s/%s", ctx->local.uri, st->path) < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
if (_backup_path(duri, ctx->remote.uri,st->path) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case REMOTE_REPLICA:
|
||||
drep = ctx->local.type;
|
||||
if (asprintf(&suri, "%s/%s", ctx->local.uri, st->path) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ( _backup_path(duri, ctx->local.uri, st->path) < 0) {
|
||||
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"instruction not allowed: %i %s",
|
||||
st->instruction, csync_instruction_str(st->instruction));
|
||||
ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
|
||||
rc = -1;
|
||||
if ( _backup_path(duri, ctx->local.uri, st->path) < 0) {
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"instruction not allowed: %i %s",st->instruction,csync_instruction_str(st->instruction));
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -1134,8 +1127,7 @@ static int _csync_conflict_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
|
||||
rc = _csync_backup_file(ctx, st, &conflict_file_name);
|
||||
|
||||
if(rc>=0)
|
||||
{
|
||||
if(rc >= 0 ) {
|
||||
rc = _csync_push_file(ctx, st);
|
||||
}
|
||||
|
||||
|
@ -1148,12 +1140,12 @@ static int _csync_conflict_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
|
||||
if( c_compare_file(uri, conflict_file_name) == 1 ) {
|
||||
/* the files are byte wise equal. The conflict can be erased. */
|
||||
if (csync_vio_local_unlink(conflict_file_name) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "REMOVE of csync conflict file %s failed.", conflict_file_name );
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "REMOVED csync conflict file %s as files are equal.",
|
||||
conflict_file_name );
|
||||
}
|
||||
if (csync_vio_local_unlink(conflict_file_name) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "REMOVE of csync conflict file %s failed.", conflict_file_name );
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "REMOVED csync conflict file %s as files are equal.",
|
||||
conflict_file_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -802,7 +802,10 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(sqlite3 *db,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite hash query fail: %s", sqlite3_errmsg(db));
|
||||
/* SQLITE_DONE says there is no further row. That's not an error. */
|
||||
if (rc != SQLITE_DONE) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite hash query fail: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "No result record found for phash = %llu",
|
||||
(long long unsigned int) phash);
|
||||
SAFE_FREE(st);
|
||||
|
|
|
@ -88,7 +88,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
|||
const char *path = NULL;
|
||||
csync_file_stat_t *st = NULL;
|
||||
csync_file_stat_t *tmp = NULL;
|
||||
int excluded;
|
||||
CSYNC_EXCLUDE_TYPE excluded;
|
||||
|
||||
if ((file == NULL) || (fs == NULL)) {
|
||||
errno = EINVAL;
|
||||
|
@ -122,9 +122,9 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
|||
|
||||
/* Check if file is excluded */
|
||||
excluded = csync_excluded(ctx, path);
|
||||
if (excluded) {
|
||||
if (excluded != CSYNC_NOT_EXCLUDED) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "%s excluded (%d)", path, excluded);
|
||||
if (excluded == 2) {
|
||||
if (excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) {
|
||||
switch (ctx->current) {
|
||||
case LOCAL_REPLICA:
|
||||
ctx->local.ignored_cleanup = c_list_append(ctx->local.ignored_cleanup, c_strdup(path));
|
||||
|
@ -135,6 +135,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +188,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
|||
st->instruction = CSYNC_INSTRUCTION_NONE;
|
||||
goto out;
|
||||
}
|
||||
if (excluded > 0 || type == CSYNC_FTW_TYPE_SLINK) {
|
||||
if (excluded > CSYNC_NOT_EXCLUDED || type == CSYNC_FTW_TYPE_SLINK) {
|
||||
st->instruction = CSYNC_INSTRUCTION_IGNORE;
|
||||
goto out;
|
||||
}
|
||||
|
@ -253,6 +254,14 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
|||
|
||||
out:
|
||||
|
||||
/* Set the ignored error string. */
|
||||
if (st->instruction == CSYNC_INSTRUCTION_IGNORE) {
|
||||
if (excluded == CSYNC_FILE_EXCLUDE_LIST) {
|
||||
st->error_string = c_strdup("File listed on ignore list.");
|
||||
} else if (excluded == CSYNC_FILE_EXCLUDE_INVALID_CHAR) {
|
||||
st->error_string = c_strdup("File contains invalid characters.");
|
||||
}
|
||||
}
|
||||
if (st->instruction != CSYNC_INSTRUCTION_NONE && st->instruction != CSYNC_INSTRUCTION_IGNORE
|
||||
&& type != CSYNC_FTW_TYPE_DIR) {
|
||||
st->child_modified = 1;
|
||||
|
|
|
@ -76,29 +76,32 @@ static void check_csync_excluded(void **state)
|
|||
int rc;
|
||||
|
||||
rc = csync_excluded(csync, ".kde/share/config/kwin.eventsrc");
|
||||
assert_int_equal(rc, 0);
|
||||
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
|
||||
rc = csync_excluded(csync, ".kde4/cache-maximegalon/cache1.txt");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded(csync, ".mozilla/plugins");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
/*
|
||||
* Test for patterns in subdirs. '.beagle' is defined as a pattern and has
|
||||
* to be found in top dir as well as in directories underneath.
|
||||
*/
|
||||
rc = csync_excluded(csync, ".beagle");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded(csync, "foo/.beagle");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
rc = csync_excluded(csync, "foo/bar/.beagle");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
|
||||
|
||||
rc = csync_excluded(csync, ".csync_journal.db");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
|
||||
rc = csync_excluded(csync, ".csync_journal.db.ctmp");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
|
||||
rc = csync_excluded(csync, "subdir/.csync_journal.db");
|
||||
assert_int_equal(rc, 1);
|
||||
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
|
||||
|
||||
rc = csync_excluded(csync, "my.directory");
|
||||
assert_int_equal(rc, CSYNC_FILE_EXCLUDE_AND_REMOVE);
|
||||
}
|
||||
|
||||
int torture_run_tests(void)
|
||||
|
|
Загрузка…
Ссылка в новой задаче