2008-02-27 20:56:47 +03:00
|
|
|
/*
|
|
|
|
* libcsync -- a library to sync a directory with another
|
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
|
|
|
|
* Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2008-07-10 12:25:12 +04:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2013-07-23 19:31:55 +04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2008-02-27 20:56:47 +03:00
|
|
|
*
|
2013-07-23 19:31:55 +04:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2008-02-27 20:56:47 +03:00
|
|
|
*/
|
|
|
|
|
2014-01-15 15:20:03 +04:00
|
|
|
#include "config_csync.h"
|
2012-03-02 19:47:34 +04:00
|
|
|
|
2008-06-09 19:19:12 +04:00
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif
|
2008-04-28 14:40:32 +04:00
|
|
|
|
2016-02-10 21:24:40 +03:00
|
|
|
#include <assert.h>
|
2008-02-27 20:56:47 +03:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-04-26 12:43:22 +04:00
|
|
|
#include <time.h>
|
2008-11-13 16:08:26 +03:00
|
|
|
#include <sys/types.h>
|
2011-04-06 18:43:04 +04:00
|
|
|
#include <stdbool.h>
|
2008-02-27 20:56:47 +03:00
|
|
|
|
|
|
|
#include "c_lib.h"
|
|
|
|
#include "csync_private.h"
|
2008-03-25 18:22:51 +03:00
|
|
|
#include "csync_exclude.h"
|
2008-04-28 18:49:21 +04:00
|
|
|
#include "csync_util.h"
|
2012-03-02 16:38:39 +04:00
|
|
|
#include "csync_misc.h"
|
2012-12-07 16:02:46 +04:00
|
|
|
#include "std/c_private.h"
|
2013-04-26 12:45:14 +04:00
|
|
|
|
2008-04-23 14:12:48 +04:00
|
|
|
#include "csync_update.h"
|
2008-05-15 15:50:34 +04:00
|
|
|
#include "csync_reconcile.h"
|
2008-04-23 14:12:48 +04:00
|
|
|
|
2008-04-22 17:58:06 +04:00
|
|
|
#include "vio/csync_vio.h"
|
|
|
|
|
2013-01-04 23:45:10 +04:00
|
|
|
#include "csync_rename.h"
|
2017-09-01 19:11:43 +03:00
|
|
|
#include "common/c_jhash.h"
|
2017-12-14 17:08:53 +03:00
|
|
|
#include "common/syncjournalfilerecord.h"
|
2014-03-24 14:35:19 +04:00
|
|
|
|
2017-12-14 17:36:19 +03:00
|
|
|
Q_LOGGING_CATEGORY(lcCSync, "sync.csync.csync", QtInfoMsg)
|
|
|
|
|
2008-04-28 15:42:10 +04:00
|
|
|
|
2017-09-14 16:50:13 +03:00
|
|
|
csync_s::csync_s(const char *localUri, OCC::SyncJournalDb *statedb)
|
|
|
|
: statedb(statedb)
|
|
|
|
{
|
2008-04-28 14:35:29 +04:00
|
|
|
size_t len = 0;
|
2008-02-27 20:56:47 +03:00
|
|
|
|
2008-04-28 14:35:29 +04:00
|
|
|
/* remove trailing slashes */
|
2017-09-04 20:06:13 +03:00
|
|
|
len = strlen(localUri);
|
|
|
|
while(len > 0 && localUri[len - 1] == '/') --len;
|
2008-02-27 20:56:47 +03:00
|
|
|
|
2017-09-04 20:06:13 +03:00
|
|
|
local.uri = c_strndup(localUri, len);
|
2008-02-27 20:56:47 +03:00
|
|
|
}
|
|
|
|
|
2008-04-23 14:12:48 +04:00
|
|
|
int csync_update(CSYNC *ctx) {
|
2008-05-15 14:03:05 +04:00
|
|
|
int rc = -1;
|
2013-05-04 18:10:11 +04:00
|
|
|
|
2020-06-10 04:47:49 +03:00
|
|
|
if (!ctx) {
|
2008-04-26 12:43:22 +04:00
|
|
|
errno = EBADF;
|
|
|
|
return -1;
|
|
|
|
}
|
2013-08-18 19:26:45 +04:00
|
|
|
ctx->status_code = CSYNC_STATUS_OK;
|
2008-04-26 12:43:22 +04:00
|
|
|
|
2013-03-12 20:01:39 +04:00
|
|
|
ctx->status_code = CSYNC_STATUS_OK;
|
|
|
|
|
2013-03-01 12:59:55 +04:00
|
|
|
csync_memstat_check();
|
2008-04-28 18:49:21 +04:00
|
|
|
|
2017-11-29 14:04:01 +03:00
|
|
|
if (!ctx->exclude_traversal_fn) {
|
2017-12-14 17:36:19 +03:00
|
|
|
qCInfo(lcCSync, "No exclude file loaded or defined!");
|
2014-03-27 20:11:19 +04:00
|
|
|
}
|
|
|
|
|
2008-05-15 14:03:05 +04:00
|
|
|
/* update detection for local replica */
|
2017-12-14 17:36:19 +03:00
|
|
|
QElapsedTimer timer;
|
|
|
|
timer.start();
|
2008-04-28 16:08:07 +04:00
|
|
|
ctx->current = LOCAL_REPLICA;
|
2008-05-15 14:03:05 +04:00
|
|
|
|
2017-12-14 18:14:08 +03:00
|
|
|
qCInfo(lcCSync, "## Starting local discovery ##");
|
2018-01-08 11:32:38 +03:00
|
|
|
|
2008-05-15 14:03:05 +04:00
|
|
|
rc = csync_ftw(ctx, ctx->local.uri, csync_walker, MAX_DEPTH);
|
2013-06-06 11:34:54 +04:00
|
|
|
if (rc < 0) {
|
2014-10-22 17:41:29 +04:00
|
|
|
if(ctx->status_code == CSYNC_STATUS_OK) {
|
2013-08-18 19:26:45 +04:00
|
|
|
ctx->status_code = csync_errno_to_status(errno, CSYNC_STATUS_UPDATE_ERROR);
|
2014-10-22 17:41:29 +04:00
|
|
|
}
|
2017-09-14 16:50:13 +03:00
|
|
|
return rc;
|
2013-06-06 11:34:54 +04:00
|
|
|
}
|
2008-05-15 14:03:05 +04:00
|
|
|
|
2017-12-14 17:36:19 +03:00
|
|
|
qCInfo(lcCSync) << "Update detection for local replica took" << timer.elapsed() / 1000.
|
|
|
|
<< "seconds walking" << ctx->local.files.size() << "files";
|
2013-03-01 12:59:55 +04:00
|
|
|
csync_memstat_check();
|
2008-04-26 12:43:22 +04:00
|
|
|
|
2008-05-15 14:03:05 +04:00
|
|
|
/* update detection for remote replica */
|
2017-12-14 17:36:19 +03:00
|
|
|
timer.restart();
|
2014-06-03 19:52:07 +04:00
|
|
|
ctx->current = REMOTE_REPLICA;
|
2008-05-15 14:03:05 +04:00
|
|
|
|
2017-12-14 18:14:08 +03:00
|
|
|
qCInfo(lcCSync, "## Starting remote discovery ##");
|
2018-01-08 11:32:38 +03:00
|
|
|
|
2016-11-15 20:47:04 +03:00
|
|
|
rc = csync_ftw(ctx, "", csync_walker, MAX_DEPTH);
|
2014-06-03 19:52:07 +04:00
|
|
|
if (rc < 0) {
|
2014-10-22 17:41:29 +04:00
|
|
|
if(ctx->status_code == CSYNC_STATUS_OK) {
|
2014-06-03 19:52:07 +04:00
|
|
|
ctx->status_code = csync_errno_to_status(errno, CSYNC_STATUS_UPDATE_ERROR);
|
2014-10-22 17:41:29 +04:00
|
|
|
}
|
2017-09-14 16:50:13 +03:00
|
|
|
return rc;
|
2014-06-03 19:52:07 +04:00
|
|
|
}
|
2008-05-15 14:03:05 +04:00
|
|
|
|
2008-04-23 14:12:48 +04:00
|
|
|
|
2017-12-14 17:36:19 +03:00
|
|
|
qCInfo(lcCSync) << "Update detection for remote replica took" << timer.elapsed() / 1000.
|
|
|
|
<< "seconds walking" << ctx->remote.files.size() << "files";
|
2014-06-03 19:52:07 +04:00
|
|
|
csync_memstat_check();
|
2008-05-15 14:03:05 +04:00
|
|
|
|
2008-05-27 16:15:44 +04:00
|
|
|
ctx->status |= CSYNC_STATUS_UPDATE;
|
2008-04-29 13:20:52 +04:00
|
|
|
|
2014-10-22 17:41:29 +04:00
|
|
|
rc = 0;
|
|
|
|
return rc;
|
2008-04-23 14:12:48 +04:00
|
|
|
}
|
|
|
|
|
2008-05-15 15:50:34 +04:00
|
|
|
int csync_reconcile(CSYNC *ctx) {
|
2018-03-06 09:13:28 +03:00
|
|
|
Q_ASSERT(ctx);
|
2013-03-12 20:01:39 +04:00
|
|
|
ctx->status_code = CSYNC_STATUS_OK;
|
2008-05-15 15:50:34 +04:00
|
|
|
|
|
|
|
/* Reconciliation for local replica */
|
2017-12-14 17:36:19 +03:00
|
|
|
QElapsedTimer timer;
|
|
|
|
timer.start();
|
2008-05-15 21:42:03 +04:00
|
|
|
|
2008-05-15 15:50:34 +04:00
|
|
|
ctx->current = LOCAL_REPLICA;
|
|
|
|
|
2018-03-06 09:13:28 +03:00
|
|
|
csync_reconcile_updates(ctx);
|
2008-05-15 15:50:34 +04:00
|
|
|
|
2017-12-14 17:36:19 +03:00
|
|
|
qCInfo(lcCSync) << "Reconciliation for local replica took " << timer.elapsed() / 1000.
|
|
|
|
<< "seconds visiting " << ctx->local.files.size() << " files.";
|
2008-05-15 15:50:34 +04:00
|
|
|
|
2014-03-24 14:35:19 +04:00
|
|
|
/* Reconciliation for remote replica */
|
2017-12-14 17:36:19 +03:00
|
|
|
timer.restart();
|
2008-05-15 21:42:03 +04:00
|
|
|
|
2012-10-19 16:23:20 +04:00
|
|
|
ctx->current = REMOTE_REPLICA;
|
2008-05-15 15:50:34 +04:00
|
|
|
|
2018-03-06 09:13:28 +03:00
|
|
|
csync_reconcile_updates(ctx);
|
2008-05-15 15:50:34 +04:00
|
|
|
|
2017-12-14 17:36:19 +03:00
|
|
|
qCInfo(lcCSync) << "Reconciliation for remote replica took " << timer.elapsed() / 1000.
|
|
|
|
<< "seconds visiting " << ctx->remote.files.size() << " files.";
|
2008-05-15 15:50:34 +04:00
|
|
|
|
2008-05-27 16:15:44 +04:00
|
|
|
ctx->status |= CSYNC_STATUS_RECONCILE;
|
2018-03-06 09:13:28 +03:00
|
|
|
return 0;
|
2008-05-15 15:50:34 +04:00
|
|
|
}
|
|
|
|
|
2012-03-19 19:05:23 +04:00
|
|
|
/*
|
|
|
|
* local visitor which calls the user visitor with repacked stat info.
|
|
|
|
*/
|
2018-03-01 15:53:55 +03:00
|
|
|
static int _csync_treewalk_visitor(csync_file_stat_t *cur, CSYNC * ctx, const csync_treewalk_visit_func &visitor) {
|
2017-08-23 20:16:12 +03:00
|
|
|
csync_s::FileMap *other_tree = nullptr;
|
2012-10-28 14:31:25 +04:00
|
|
|
|
2014-03-24 14:35:19 +04:00
|
|
|
/* we need the opposite tree! */
|
|
|
|
switch (ctx->current) {
|
|
|
|
case LOCAL_REPLICA:
|
2017-08-23 20:16:12 +03:00
|
|
|
other_tree = &ctx->remote.files;
|
2014-03-24 14:35:19 +04:00
|
|
|
break;
|
|
|
|
case REMOTE_REPLICA:
|
2017-08-23 20:16:12 +03:00
|
|
|
other_tree = &ctx->local.files;
|
2014-03-24 14:35:19 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-08-23 20:16:12 +03:00
|
|
|
csync_s::FileMap::const_iterator other_file_it = other_tree->find(cur->path);
|
2014-03-24 14:35:19 +04:00
|
|
|
|
2017-08-23 20:16:12 +03:00
|
|
|
if (other_file_it == other_tree->cend()) {
|
2014-03-24 14:35:19 +04:00
|
|
|
/* Check the renamed path as well. */
|
2017-12-05 15:42:55 +03:00
|
|
|
QByteArray renamed_path = csync_rename_adjust_parent_path(ctx, cur->path);
|
2017-08-23 20:16:12 +03:00
|
|
|
if (renamed_path != cur->path)
|
|
|
|
other_file_it = other_tree->find(renamed_path);
|
2014-03-24 14:35:19 +04:00
|
|
|
}
|
|
|
|
|
2017-08-23 20:16:12 +03:00
|
|
|
if (other_file_it == other_tree->cend()) {
|
2015-05-12 17:32:00 +03:00
|
|
|
/* Check the source path as well. */
|
2017-12-05 15:42:55 +03:00
|
|
|
QByteArray renamed_path = csync_rename_adjust_parent_path_source(ctx, cur->path);
|
2017-08-23 20:16:12 +03:00
|
|
|
if (renamed_path != cur->path)
|
|
|
|
other_file_it = other_tree->find(renamed_path);
|
2015-05-12 17:32:00 +03:00
|
|
|
}
|
|
|
|
|
2020-05-18 21:39:16 +03:00
|
|
|
csync_file_stat_t *other = (other_file_it != other_tree->cend()) ? other_file_it->second.get() : nullptr;
|
2017-08-17 15:39:23 +03:00
|
|
|
|
2013-08-18 19:26:45 +04:00
|
|
|
ctx->status_code = CSYNC_STATUS_OK;
|
2012-04-17 14:31:27 +04:00
|
|
|
|
2018-03-01 15:53:55 +03:00
|
|
|
Q_ASSERT(visitor);
|
|
|
|
return visitor(cur, other);
|
2012-03-19 19:05:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* treewalk function, called from its wrappers below.
|
|
|
|
*/
|
2018-03-01 15:53:55 +03:00
|
|
|
static int _csync_walk_tree(CSYNC *ctx, csync_s::FileMap &tree, const csync_treewalk_visit_func &visitor)
|
2012-03-19 19:05:23 +04:00
|
|
|
{
|
2018-03-01 15:53:55 +03:00
|
|
|
for (auto &pair : tree) {
|
|
|
|
if (_csync_treewalk_visitor(pair.second.get(), ctx, visitor) < 0) {
|
|
|
|
return -1;
|
2017-08-23 20:16:12 +03:00
|
|
|
}
|
|
|
|
}
|
2018-03-01 15:53:55 +03:00
|
|
|
return 0;
|
2012-03-19 19:05:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wrapper function for treewalk on the remote tree
|
|
|
|
*/
|
2018-03-01 15:53:55 +03:00
|
|
|
int csync_walk_remote_tree(CSYNC *ctx, const csync_treewalk_visit_func &visitor)
|
2012-03-19 19:05:23 +04:00
|
|
|
{
|
2017-08-23 20:16:12 +03:00
|
|
|
ctx->status_code = CSYNC_STATUS_OK;
|
|
|
|
ctx->current = REMOTE_REPLICA;
|
2018-03-01 15:53:55 +03:00
|
|
|
return _csync_walk_tree(ctx, ctx->remote.files, visitor);
|
2012-03-19 19:05:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wrapper function for treewalk on the local tree
|
|
|
|
*/
|
2018-03-01 15:53:55 +03:00
|
|
|
int csync_walk_local_tree(CSYNC *ctx, const csync_treewalk_visit_func &visitor)
|
2012-03-19 19:05:23 +04:00
|
|
|
{
|
2017-08-23 20:16:12 +03:00
|
|
|
ctx->status_code = CSYNC_STATUS_OK;
|
|
|
|
ctx->current = LOCAL_REPLICA;
|
2018-03-01 15:53:55 +03:00
|
|
|
return _csync_walk_tree(ctx, ctx->local.files, visitor);
|
2008-04-28 15:42:10 +04:00
|
|
|
}
|
|
|
|
|
2017-09-04 20:06:13 +03:00
|
|
|
int csync_s::reinitialize() {
|
2013-04-20 12:51:27 +04:00
|
|
|
int rc = 0;
|
|
|
|
|
2017-09-04 20:06:13 +03:00
|
|
|
status_code = CSYNC_STATUS_OK;
|
2013-05-08 17:28:26 +04:00
|
|
|
|
2020-05-20 09:52:26 +03:00
|
|
|
remote.read_from_db = false;
|
2017-09-04 20:06:13 +03:00
|
|
|
read_remote_from_db = true;
|
2013-10-31 13:05:15 +04:00
|
|
|
|
2017-08-23 20:16:12 +03:00
|
|
|
local.files.clear();
|
|
|
|
remote.files.clear();
|
2013-05-06 19:14:17 +04:00
|
|
|
|
2017-12-05 15:41:27 +03:00
|
|
|
renames.folder_renamed_from.clear();
|
|
|
|
renames.folder_renamed_to.clear();
|
|
|
|
|
2017-09-04 20:06:13 +03:00
|
|
|
status = CSYNC_STATUS_INIT;
|
|
|
|
SAFE_FREE(error_string);
|
2013-04-22 17:39:43 +04:00
|
|
|
|
2013-04-24 16:35:19 +04:00
|
|
|
rc = 0;
|
2013-04-20 12:51:27 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-09-04 20:06:13 +03:00
|
|
|
csync_s::~csync_s() {
|
|
|
|
SAFE_FREE(local.uri);
|
|
|
|
SAFE_FREE(error_string);
|
2008-02-27 20:56:47 +03:00
|
|
|
}
|
|
|
|
|
2009-03-26 13:09:46 +03:00
|
|
|
void *csync_get_userdata(CSYNC *ctx) {
|
2020-06-10 04:47:49 +03:00
|
|
|
if (!ctx) {
|
2020-05-18 21:39:16 +03:00
|
|
|
return nullptr;
|
2009-03-26 13:09:46 +03:00
|
|
|
}
|
2012-10-27 17:10:16 +04:00
|
|
|
return ctx->callbacks.userdata;
|
2009-03-26 13:09:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int csync_set_userdata(CSYNC *ctx, void *userdata) {
|
2020-06-10 04:47:49 +03:00
|
|
|
if (!ctx) {
|
2009-03-26 13:09:46 +03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-27 17:10:16 +04:00
|
|
|
ctx->callbacks.userdata = userdata;
|
2009-03-26 13:09:46 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-24 15:36:27 +04:00
|
|
|
csync_auth_callback csync_get_auth_callback(CSYNC *ctx) {
|
2020-06-10 04:47:49 +03:00
|
|
|
if (!ctx) {
|
2020-05-18 21:39:16 +03:00
|
|
|
return nullptr;
|
2008-05-20 18:33:03 +04:00
|
|
|
}
|
|
|
|
|
2012-10-27 17:10:16 +04:00
|
|
|
return ctx->callbacks.auth_function;
|
2012-10-27 17:15:59 +04:00
|
|
|
}
|
|
|
|
|
2008-05-20 18:33:03 +04:00
|
|
|
int csync_set_status(CSYNC *ctx, int status) {
|
2020-06-10 04:47:49 +03:00
|
|
|
if (!ctx || status < 0) {
|
2008-05-20 18:33:03 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-05-05 13:09:16 +04:00
|
|
|
ctx->status = status;
|
2008-05-20 18:33:03 +04:00
|
|
|
|
|
|
|
return 0;
|
2008-05-05 13:09:16 +04:00
|
|
|
}
|
|
|
|
|
2013-11-25 01:17:36 +04:00
|
|
|
CSYNC_STATUS csync_get_status(CSYNC *ctx) {
|
2020-06-10 04:47:49 +03:00
|
|
|
if (!ctx) {
|
2017-08-14 17:19:52 +03:00
|
|
|
return CSYNC_STATUS_ERROR;
|
2008-06-24 13:13:56 +04:00
|
|
|
}
|
|
|
|
|
2013-11-25 01:17:36 +04:00
|
|
|
return ctx->status_code;
|
2012-02-27 15:18:02 +04:00
|
|
|
}
|
|
|
|
|
2013-03-13 17:46:08 +04:00
|
|
|
const char *csync_get_status_string(CSYNC *ctx)
|
2012-12-04 16:42:16 +04:00
|
|
|
{
|
2013-03-13 17:46:08 +04:00
|
|
|
return csync_vio_get_status_string(ctx);
|
2012-12-04 16:42:16 +04:00
|
|
|
}
|
|
|
|
|
2013-05-08 19:33:50 +04:00
|
|
|
void csync_request_abort(CSYNC *ctx)
|
2013-05-08 17:28:26 +04:00
|
|
|
{
|
2020-06-10 04:47:49 +03:00
|
|
|
if (ctx) {
|
2013-05-08 17:28:26 +04:00
|
|
|
ctx->abort = true;
|
2013-05-16 19:37:30 +04:00
|
|
|
}
|
2013-05-08 17:28:26 +04:00
|
|
|
}
|
|
|
|
|
2013-05-08 19:33:50 +04:00
|
|
|
void csync_resume(CSYNC *ctx)
|
|
|
|
{
|
2020-06-10 04:47:49 +03:00
|
|
|
if (ctx) {
|
2013-05-08 19:33:50 +04:00
|
|
|
ctx->abort = false;
|
2013-05-16 19:37:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int csync_abort_requested(CSYNC *ctx)
|
|
|
|
{
|
2020-06-10 04:47:49 +03:00
|
|
|
if (ctx) {
|
2013-05-16 19:37:30 +04:00
|
|
|
return ctx->abort;
|
|
|
|
} else {
|
|
|
|
return (1 == 0);
|
|
|
|
}
|
2013-05-08 19:33:50 +04:00
|
|
|
}
|
2017-12-14 17:08:53 +03:00
|
|
|
|
|
|
|
std::unique_ptr<csync_file_stat_t> csync_file_stat_s::fromSyncJournalFileRecord(const OCC::SyncJournalFileRecord &rec)
|
|
|
|
{
|
|
|
|
std::unique_ptr<csync_file_stat_t> st(new csync_file_stat_t);
|
|
|
|
st->path = rec._path;
|
|
|
|
st->inode = rec._inode;
|
|
|
|
st->modtime = rec._modtime;
|
|
|
|
st->type = static_cast<ItemType>(rec._type);
|
|
|
|
st->etag = rec._etag;
|
|
|
|
st->file_id = rec._fileId;
|
|
|
|
st->remotePerm = rec._remotePerm;
|
|
|
|
st->size = rec._fileSize;
|
|
|
|
st->has_ignored_files = rec._serverHasIgnoredFiles;
|
|
|
|
st->checksumHeader = rec._checksumHeader;
|
2018-02-12 14:50:51 +03:00
|
|
|
st->e2eMangledName = rec._e2eMangledName;
|
2017-12-14 17:08:53 +03:00
|
|
|
return st;
|
|
|
|
}
|