mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 21:35:47 +03:00
Experimental: Fix the mv and recreate case as described in mirall#731.
Please note that this needs review and test and probably does not fully fix it. It just makes sure that renames are handled before PUTs.
This commit is contained in:
parent
7ef620f58d
commit
7eb3f901a6
1 changed files with 50 additions and 6 deletions
|
@ -1422,6 +1422,52 @@ static int _csync_propagation_cleanup(CSYNC *ctx) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int _csync_propagation_rename_file_visitor(void *obj, void *data) {
|
||||
csync_file_stat_t *st = NULL;
|
||||
CSYNC *ctx = NULL;
|
||||
int rc = 0;
|
||||
|
||||
st = (csync_file_stat_t *) obj;
|
||||
ctx = (CSYNC *) data;
|
||||
|
||||
if (ctx->abort) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Aborted!");
|
||||
ctx->error_code = CSYNC_ERR_ABORTED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(st->type) {
|
||||
case CSYNC_FTW_TYPE_SLINK:
|
||||
break;
|
||||
case CSYNC_FTW_TYPE_FILE:
|
||||
switch (st->instruction) {
|
||||
case CSYNC_INSTRUCTION_RENAME:
|
||||
if ((rc = _csync_rename_file(ctx, st)) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"FAIL RENAME: %s",st->path);
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CSYNC_FTW_TYPE_DIR:
|
||||
/*
|
||||
* We have to walk over the files first. If you create or rename a file
|
||||
* in a directory on unix. The modification time of the directory gets
|
||||
* changed.
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int _csync_propagation_file_visitor(void *obj, void *data) {
|
||||
csync_file_stat_t *st = NULL;
|
||||
CSYNC *ctx = NULL;
|
||||
|
@ -1447,12 +1493,6 @@ static int _csync_propagation_file_visitor(void *obj, void *data) {
|
|||
goto err;
|
||||
}
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_RENAME:
|
||||
if ((rc = _csync_rename_file(ctx, st)) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"FAIL RENAME: %s",st->path);
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_SYNC:
|
||||
if ((rc = _csync_sync_file(ctx, st)) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE,"FAIL SYNC: %s",st->path);
|
||||
|
@ -1567,6 +1607,10 @@ int csync_propagate_files(CSYNC *ctx) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (c_rbtree_walk(tree, (void *) ctx, _csync_propagation_rename_file_visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (c_rbtree_walk(tree, (void *) ctx, _csync_propagation_file_visitor) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue