[Pkg-owncloud-commits] [owncloud-client] 31/175: csync walk tree: Try to find the 'other_node' in the source directory in case of renames
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 505dba5b23a110d5ef91885c31d45676585a56f8
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue May 12 16:32:00 2015 +0200
csync walk tree: Try to find the 'other_node' in the source directory in case of renames
This fixes t2.pl
---
csync/src/csync.c | 14 ++++++++++++++
csync/src/csync_rename.cc | 16 ++++++++++++++++
csync/src/csync_rename.h | 3 +++
3 files changed, 33 insertions(+)
diff --git a/csync/src/csync.c b/csync/src/csync.c
index 65a0655..5f72079 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -386,6 +386,20 @@ static int _csync_treewalk_visitor(void *obj, void *data) {
SAFE_FREE(renamed_path);
}
+ if (!other_node) {
+ /* Check the source path as well. */
+ int len;
+ uint64_t h = 0;
+ char *renamed_path = csync_rename_adjust_path_source(ctx, cur->path);
+
+ if (!c_streq(renamed_path, cur->path)) {
+ len = strlen( renamed_path );
+ h = c_jhash64((uint8_t *) renamed_path, len, 0);
+ other_node = c_rbtree_find(other_tree, &h);
+ }
+ SAFE_FREE(renamed_path);
+ }
+
if (obj == NULL || data == NULL) {
ctx->status_code = CSYNC_STATUS_PARAM_ERROR;
return -1;
diff --git a/csync/src/csync_rename.cc b/csync/src/csync_rename.cc
index 64da49a..f7c77a4 100644
--- a/csync/src/csync_rename.cc
+++ b/csync/src/csync_rename.cc
@@ -43,6 +43,7 @@ struct csync_rename_s {
}
std::map<std::string, std::string> folder_renamed_to; // map from->to
+ std::map<std::string, std::string> folder_renamed_from; // map to->from
struct renameop {
csync_file_stat_t *st;
@@ -63,6 +64,7 @@ void csync_rename_destroy(CSYNC* ctx)
void csync_rename_record(CSYNC* ctx, const char* from, const char* to)
{
csync_rename_s::get(ctx)->folder_renamed_to[from] = to;
+ csync_rename_s::get(ctx)->folder_renamed_from[to] = from;
}
char* csync_rename_adjust_path(CSYNC* ctx, const char* path)
@@ -78,4 +80,18 @@ char* csync_rename_adjust_path(CSYNC* ctx, const char* path)
return c_strdup(path);
}
+char* csync_rename_adjust_path_source(CSYNC* ctx, const char* path)
+{
+ csync_rename_s* d = csync_rename_s::get(ctx);
+ for (std::string p = _parentDir(path); !p.empty(); p = _parentDir(p)) {
+ std::map< std::string, std::string >::iterator it = d->folder_renamed_from.find(p);
+ if (it != d->folder_renamed_from.end()) {
+ std::string rep = it->second + (path + p.length());
+ return c_strdup(rep.c_str());
+ }
+ }
+ return c_strdup(path);
+}
+
+
}
diff --git a/csync/src/csync_rename.h b/csync/src/csync_rename.h
index 7524769..a4f50a0 100644
--- a/csync/src/csync_rename.h
+++ b/csync/src/csync_rename.h
@@ -26,7 +26,10 @@
extern "C" {
#endif
+/* Return the final destination path of a given patch in case of renames */
char *csync_rename_adjust_path(CSYNC *ctx, const char *path);
+/* Return the source of a given path in case of renames */
+char *csync_rename_adjust_path_source(CSYNC *ctx, const char *path);
void csync_rename_destroy(CSYNC *ctx);
void csync_rename_record(CSYNC *ctx, const char *from, const char *to);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list