mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 12:25:35 +02:00
Remove GGP dependencies from CDC RSync (#1)
* Remove dependencies of cdc_sync from GGP Allows overriding the SSH and SCP commands via command line flags. Hence, strict host checking, SSH config etc. can be removed since it is passed in by command line flags for GGP. Also deploys cdc_rsync_server to ~/.cache/cdc_file_transfer/ and creates that dir if it does not exist. * Tweak RemoteUtil Replaces localhost: by //./ in the workaround for scp since localhost: had two disadvantages: 1) It required 2 gnubby touches for gLinux and 2) it didn't work for ggp. //./ works for both. Also tweaks quoting, which didn't quite work for ggp. * Don't check remote ports in cdc_rsync Turns off checking remote ports in PortManager. In the future, the server should return available ports after failing to connect to the provided port. Since now the first remote connection is running cdc_rsync_server, the timeout check has to be done when running that process. * Remove now-unused kInstancePickerNotAvailableInQuietMode enum * Add more details to the readme * [cdc_rsync] Accept [user@]host:destination Removes the --ip command line argument and assumes user/host are passed in along with the destination, so it works in the same way as other popular tools. * [ggp_rsync] Combine server deploy commands Combines two chmod and one mv command into one ssh command. This makes deploy a bit quicker, especially if each ssh command involves touching your gnubby. * Remove GGP specific stuff from VS build commands * [cdc_rsync] Get rid of cdc_rsync.dll Compile the CDC RSync client as a static library instead. This removes quite a bit of boiler plate and makes string handling easier since we can now pass std::strings instead of const chars. Also fixes an issue where we were sometimes trying to assign nullptr to std::strings, which is forbidden. * Allow specifying ssh/scp commands with env vars * Rename GgpRsync* to CdcRsync* * Merge ggp_rsync_cli into ggp_rsync * [cdc_rsync] Refactor cdc_rsync.cc/h Merges cdc_rsync.cc/h with main.cc and CdcRsyncClient since code is closer to where it's being used and should be more readable.
This commit is contained in:
@@ -146,14 +146,14 @@ PathFilter::Rule::Type ToInternalType(
|
||||
|
||||
} // namespace
|
||||
|
||||
GgpRsyncServer::GgpRsyncServer() = default;
|
||||
CdcRsyncServer::CdcRsyncServer() = default;
|
||||
|
||||
GgpRsyncServer::~GgpRsyncServer() {
|
||||
CdcRsyncServer::~CdcRsyncServer() {
|
||||
message_pump_.reset();
|
||||
socket_.reset();
|
||||
}
|
||||
|
||||
bool GgpRsyncServer::CheckComponents(
|
||||
bool CdcRsyncServer::CheckComponents(
|
||||
const std::vector<GameletComponent>& components) {
|
||||
// Components are expected to reside in the same dir as the executable.
|
||||
std::string component_dir;
|
||||
@@ -172,7 +172,7 @@ bool GgpRsyncServer::CheckComponents(
|
||||
return true;
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::Run(int port) {
|
||||
absl::Status CdcRsyncServer::Run(int port) {
|
||||
socket_ = std::make_unique<ServerSocket>();
|
||||
absl::Status status = socket_->StartListening(port);
|
||||
if (!status.ok()) {
|
||||
@@ -205,7 +205,7 @@ absl::Status GgpRsyncServer::Run(int port) {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::Sync() {
|
||||
absl::Status CdcRsyncServer::Sync() {
|
||||
// First, the client sends us options, e.g. the |destination_| directory.
|
||||
absl::Status status = HandleSetOptions();
|
||||
if (!status.ok()) {
|
||||
@@ -281,7 +281,7 @@ absl::Status GgpRsyncServer::Sync() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::HandleSetOptions() {
|
||||
absl::Status CdcRsyncServer::HandleSetOptions() {
|
||||
LOG_INFO("Receiving options");
|
||||
|
||||
SetOptionsRequest request;
|
||||
@@ -324,7 +324,7 @@ absl::Status GgpRsyncServer::HandleSetOptions() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::FindFiles() {
|
||||
absl::Status CdcRsyncServer::FindFiles() {
|
||||
Stopwatch stopwatch;
|
||||
FileFinder finder;
|
||||
|
||||
@@ -350,7 +350,7 @@ absl::Status GgpRsyncServer::FindFiles() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::HandleSendAllFiles() {
|
||||
absl::Status CdcRsyncServer::HandleSendAllFiles() {
|
||||
std::string current_directory;
|
||||
|
||||
for (;;) {
|
||||
@@ -385,7 +385,7 @@ absl::Status GgpRsyncServer::HandleSendAllFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::DiffFiles() {
|
||||
absl::Status CdcRsyncServer::DiffFiles() {
|
||||
LOG_INFO("Diffing files");
|
||||
|
||||
// Be sure to move the data. It can grow quite large with millions of files.
|
||||
@@ -412,7 +412,7 @@ absl::Status GgpRsyncServer::DiffFiles() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::RemoveExtraneousFilesAndDirs() {
|
||||
absl::Status CdcRsyncServer::RemoveExtraneousFilesAndDirs() {
|
||||
FileDeleterAndSender deleter(message_pump_.get());
|
||||
|
||||
// To guarantee that the folders are empty before they are removed, files are
|
||||
@@ -451,7 +451,7 @@ absl::Status GgpRsyncServer::RemoveExtraneousFilesAndDirs() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::CreateMissingDirs() {
|
||||
absl::Status CdcRsyncServer::CreateMissingDirs() {
|
||||
for (const DirInfo& dir : diff_.missing_dirs) {
|
||||
// Make directory.
|
||||
std::string path = path::Join(destination_, dir.filepath);
|
||||
@@ -475,7 +475,7 @@ absl::Status GgpRsyncServer::CreateMissingDirs() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
absl::Status GgpRsyncServer::SendFileIndices(const char* file_type,
|
||||
absl::Status CdcRsyncServer::SendFileIndices(const char* file_type,
|
||||
const std::vector<T>& files) {
|
||||
LOG_INFO("Sending indices of missing files to client");
|
||||
constexpr char error_fmt[] = "Failed to send indices of %s files.";
|
||||
@@ -516,7 +516,7 @@ absl::Status GgpRsyncServer::SendFileIndices(const char* file_type,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::HandleSendMissingFileData() {
|
||||
absl::Status CdcRsyncServer::HandleSendMissingFileData() {
|
||||
if (diff_.missing_files.empty()) {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -641,7 +641,7 @@ absl::Status GgpRsyncServer::HandleSendMissingFileData() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::SyncChangedFiles() {
|
||||
absl::Status CdcRsyncServer::SyncChangedFiles() {
|
||||
if (diff_.changed_files.empty()) {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -729,7 +729,7 @@ absl::Status GgpRsyncServer::SyncChangedFiles() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GgpRsyncServer::HandleShutdown() {
|
||||
absl::Status CdcRsyncServer::HandleShutdown() {
|
||||
ShutdownRequest request;
|
||||
absl::Status status =
|
||||
message_pump_->ReceiveMessage(PacketType::kShutdown, &request);
|
||||
@@ -746,7 +746,7 @@ absl::Status GgpRsyncServer::HandleShutdown() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void GgpRsyncServer::Thread_OnPackageReceived(PacketType type) {
|
||||
void CdcRsyncServer::Thread_OnPackageReceived(PacketType type) {
|
||||
if (type != PacketType::kToggleCompression) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user