From 36f4dc925107a9ecddcecdec57fb7e94d90835e2 Mon Sep 17 00:00:00 2001 From: Levon Ter-Grigoryan Date: Wed, 25 Jan 2023 17:17:31 +0100 Subject: [PATCH] [cdc_rsync] [cdc_rsync_server] Add build ID Build id is an optional unique identifier specified during cdc_rsync build via CDC_BUILD_VERSION definition. If build id specified on both client and server components it will be used to check the version of server component instead of file size + modified time. --- all_files.vcxitems | 1 + cdc_rsync/BUILD | 1 + cdc_rsync/params.cc | 6 +++-- cdc_rsync_server/BUILD | 1 + cdc_rsync_server/main.cc | 16 ++++++++++---- common/BUILD | 6 +++++ common/build_version.h | 10 +++++++++ common/gamelet_component.cc | 38 +++++++++++++++++++++++--------- common/gamelet_component.h | 4 +++- common/gamelet_component_test.cc | 37 +++++++++++++++++++++++++++++-- 10 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 common/build_version.h diff --git a/all_files.vcxitems b/all_files.vcxitems index 6731d57..75efda4 100644 --- a/all_files.vcxitems +++ b/all_files.vcxitems @@ -159,6 +159,7 @@ + diff --git a/cdc_rsync/BUILD b/cdc_rsync/BUILD index 29a4fed..e285750 100644 --- a/cdc_rsync/BUILD +++ b/cdc_rsync/BUILD @@ -131,6 +131,7 @@ cc_library( hdrs = ["params.h"], deps = [ ":cdc_rsync_client", + "//common:build_version", "//common:port_range_parser", "@com_github_zstd//:zstd", "@com_google_absl//absl/status", diff --git a/cdc_rsync/params.cc b/cdc_rsync/params.cc index a74c17c..8f92d31 100644 --- a/cdc_rsync/params.cc +++ b/cdc_rsync/params.cc @@ -19,6 +19,7 @@ #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/strings/str_split.h" +#include "common/build_version.h" #include "common/path.h" #include "common/port_range_parser.h" #include "common/remote_util.h" @@ -38,8 +39,7 @@ void PrintError(const absl::FormatSpec& format, Args... args) { enum class OptionResult { kConsumedKey, kConsumedKeyValue, kError }; const char kHelpText[] = - R"(Synchronize files and directories - + R"( Matching files are skipped based on file size and modified time. For partially matching files only the differences are transferred. The destination directory can be the same Windows machine or a remote Windows or Linux device. @@ -323,6 +323,8 @@ OptionResult HandleParameter(const std::string& key, const char* value, bool ValidateParameters(const Parameters& params, bool help) { if (help) { + std::cout << "cdc_rsync - Synchronize files and directories. Version: " + << BUILD_VERSION << "\n"; std::cout << kHelpText; return false; } diff --git a/cdc_rsync_server/BUILD b/cdc_rsync_server/BUILD index e6c9551..8b69391 100644 --- a/cdc_rsync_server/BUILD +++ b/cdc_rsync_server/BUILD @@ -100,6 +100,7 @@ cc_binary( "//cdc_rsync/base:cdc_interface", "//cdc_rsync/base:message_pump", "//cdc_rsync/base:server_exit_code", + "//common:build_version", "//common:clock", "//common:gamelet_component", "//common:log", diff --git a/cdc_rsync_server/main.cc b/cdc_rsync_server/main.cc index 0fef17d..2ef0eef 100644 --- a/cdc_rsync_server/main.cc +++ b/cdc_rsync_server/main.cc @@ -14,6 +14,7 @@ #include "cdc_rsync/base/server_exit_code.h" #include "cdc_rsync_server/cdc_rsync_server.h" +#include "common/build_version.h" #include "common/gamelet_component.h" #include "common/log.h" #include "common/status.h" @@ -60,10 +61,16 @@ ServerExitCode GetExitCode(const absl::Status& status) { } // namespace cdc_ft int main(int argc, const char** argv) { - if (argc < 2) { - printf("Usage: cdc_rsync_server cdc_rsync_server