mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 14:45:37 +02:00
[cdc_rsync] Enable local syncing (#75)
Adds support for local syncs of files and folders on the same Windows machine, e.g. cdc_rsync C:\source C:\dest. The two main changes are - Skip the check whether the port is available remotely with PortManager. - Do not deploy cdc_rsync_server. - Run cdc_rsync_server directly, not through an SSH tunnel. The current implementation is not optimal as it starts cdc_rsync_server as a separate process and communicates to it via a TCP port.
This commit is contained in:
@@ -291,8 +291,8 @@ std::string GetDrivePrefix(const std::string& path) {
|
||||
|
||||
if (path[0] != '\\') {
|
||||
size_t pos = path.find(":");
|
||||
if (pos == std::string::npos) {
|
||||
// E.g. "\path\to\file" or "path\to\file".
|
||||
if (pos != 1) {
|
||||
// E.g. "\path\to\file", "path\to\file" or "user@host:file".
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
@@ -302,6 +302,7 @@ TEST_F(PathTest, GetDrivePrefix) {
|
||||
EXPECT_EQ(path::GetDrivePrefix("C:\\"), "C:");
|
||||
EXPECT_EQ(path::GetDrivePrefix("C:\\dir"), "C:");
|
||||
EXPECT_EQ(path::GetDrivePrefix("C:\\dir\\file"), "C:");
|
||||
EXPECT_EQ(path::GetDrivePrefix("host:C:\\dir\\file"), "");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ class PortManager {
|
||||
// synchronize port reservation. The range of possible ports managed by this
|
||||
// instance is [|first_port|, |last_port|]. |process_factory| is a valid
|
||||
// pointer to a ProcessFactory instance to run processes locally.
|
||||
// |remote_util| is a valid pointer to a RemoteUtil instance to run processes
|
||||
// remotely.
|
||||
// |remote_util| is the RemoteUtil instance to run processes remotely. If it
|
||||
// is nullptr, no remote ports are reserved.
|
||||
PortManager(std::string unique_name, int first_port, int last_port,
|
||||
ProcessFactory* process_factory, RemoteUtil* remote_util,
|
||||
SystemClock* system_clock = DefaultSystemClock::GetInstance(),
|
||||
|
||||
@@ -131,11 +131,13 @@ absl::StatusOr<int> PortManager::ReservePort(int remote_timeout_sec) {
|
||||
|
||||
// Find available port on remote instance.
|
||||
std::unordered_set<int> remote_ports = local_ports;
|
||||
ASSIGN_OR_RETURN(remote_ports,
|
||||
FindAvailableRemotePorts(first_port_, last_port_, "0.0.0.0",
|
||||
process_factory_, remote_util_,
|
||||
remote_timeout_sec, steady_clock_),
|
||||
"Failed to find available ports on instance");
|
||||
if (remote_util_ != nullptr) {
|
||||
ASSIGN_OR_RETURN(remote_ports,
|
||||
FindAvailableRemotePorts(
|
||||
first_port_, last_port_, "0.0.0.0", process_factory_,
|
||||
remote_util_, remote_timeout_sec, steady_clock_),
|
||||
"Failed to find available ports on instance");
|
||||
}
|
||||
|
||||
// Fetch shared memory.
|
||||
void* mem;
|
||||
|
||||
Reference in New Issue
Block a user