summaryrefslogtreecommitdiffstats
path: root/src/merge.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/merge.c')
-rw-r--r--src/merge.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/src/merge.c b/src/merge.c
index c095f1f..4c77e43 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -149,29 +149,6 @@ static int conflict_phase(DB *ddb, struct syrep_name *name, struct diff_entry *d
return 0;
}
-static char *escape_path(const char *path, char *dst, unsigned l) {
- const char *p;
- char *d;
-
- for (p = path, d = dst; *p && d-dst < l-1; p++) {
- if (*p == '/') {
- *(d++) = '%';
- *(d++) = '2';
- *(d++) = 'F';
-
- } else if (*p == '%') {
- *(d++) = '%';
- *(d++) = '2';
- *(d++) = '5';
-
- } else
- *(d++) = *p;
- }
-
- *(d++) = 0;
- return dst;
-}
-
static int copy_phase(DB *ddb, struct syrep_name *name, struct diff_entry *de, void *p) {
struct cb_info *cb_info = p;
struct syrep_name name2;
@@ -230,17 +207,15 @@ static int copy_phase(DB *ddb, struct syrep_name *name, struct diff_entry *de, v
if (copy_proc(path2, path, 0) < 0)
return -1;
} else {
- unsigned l;
-
- snprintf(path2, sizeof(path2), "%s/", cb_info->trash_dir);
- l = strlen(path2);
- escape_path(name2.path, path2+l, sizeof(path2)-l);
+ snprintf(path2, sizeof(path2), "%s/%s", cb_info->trash_dir, name2.path);
if (!access(path2, R_OK)) {
if (copy_proc(path2, path, de->action == DIFF_REPLACE) < 0)
return -1;
- } else
+ } else {
fprintf(stderr, "COPY: Local file <%s> vanished. Snapshot not up to date.\n", name2.path);
+ return -1;
+ }
}
} else {
@@ -282,7 +257,6 @@ static int copy_phase(DB *ddb, struct syrep_name *name, struct diff_entry *de, v
static int delete_phase(DB *ddb, struct syrep_name *name, struct diff_entry *de, void *p) {
struct cb_info *cb_info = p;
char path[PATH_MAX], target[PATH_MAX];
- unsigned l;
assert(ddb && name && de && p);
@@ -331,18 +305,19 @@ static int delete_phase(DB *ddb, struct syrep_name *name, struct diff_entry *de,
return 0;
}
- snprintf(target, sizeof(target), "%s/", cb_info->trash_dir);
- l = strlen(target);
- escape_path(name->path, target+l, sizeof(target)-l);
+ snprintf(target, sizeof(target), "%s/%s", cb_info->trash_dir, name->path);
- fprintf(stderr, "DELETE: Moving file <%s> into trash (%s)\n", path, target);
+ if (args.verbose_flag)
+ fprintf(stderr, "DELETE: Moving file <%s> to <%s>\n", path, target);
+ if (makeprefixpath(target, 0777) < 0)
+ return -1;
+
if (move_file(path, target, 1) < 0)
return -1;
if (args.prune_empty_flag)
- if (prune_empty_directories(path, cb_info->root) < 0)
- return -1;
+ prune_empty_directories(path, cb_info->root);
return 0;
}