tPeer localhost data with other peers - synk - synchronize files between hosts
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 6dc505684ce6858d82889b8c487b768daaa3533d
(DIR) parent 6ea0770423ed8bc445f150d43a6e18beeeb9bb25
(HTM) Author: Willy <willyatmailoodotorg>
Date: Tue, 6 Sep 2016 08:46:01 +0200
Peer localhost data with other peers
Diffstat:
M synk.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/synk.c b/synk.c
t@@ -537,9 +537,15 @@ syncfile(struct peers_t *plist, const char *fn)
if (!local)
return -1;
+ addpeer(plist, "localhost", 0);
SLIST_FOREACH(tmp, plist, entries) {
- if (getpeermeta(tmp, local) != 0)
- return -1;
+ if (IS_LOOPBACK(tmp)) {
+ memcpy(&tmp->meta, local, sizeof(struct metadata_t));
+ } else {
+ if (getpeermeta(tmp, local) != 0)
+ return -1;
+ }
+
log(LOG_VERBOSE, "peer: %s\t%s\t%.7s\t%lu\n",
tmp->host,
tmp->meta.path,
t@@ -547,16 +553,6 @@ syncfile(struct peers_t *plist, const char *fn)
tmp->meta.mtime);
}
- addpeer(plist, "localhost", 0);
- tmp = SLIST_FIRST(plist);
- tmp->meta = *local;
-
- log(LOG_VERBOSE, "peer: %s\t%s\t%.7s\t%lu\n",
- tmp->host,
- tmp->meta.path,
- sha512_format(tmp->meta.hash),
- tmp->meta.mtime);
-
if (!uptodate(plist)) {
master = freshestpeer(plist);
ret = syncwithmaster(master, plist);