Expand path variables for sync destination (#18)

Expand path variables for sync destination

Running commands like cdc_rsync C:\assets\* host:~/assets -vr would create a directory called ~assets. This CL expands path variables properly.
This commit is contained in:
Lutz Justen
2022-11-25 14:21:21 +01:00
committed by GitHub
parent 991f61cc4d
commit 8c4a0465e9
5 changed files with 19 additions and 13 deletions

View File

@@ -303,7 +303,7 @@ absl::Status CdcRsyncServer::HandleSetOptions() {
existing_ = request.existing();
copy_dest_ = request.copy_dest();
// (internal): Support \ instead of / in destination folders.
// Support \ instead of / in destination folders.
path::FixPathSeparators(&destination_);
path::EnsureEndsWithPathSeparator(&destination_);
if (!copy_dest_.empty()) {
@@ -311,6 +311,13 @@ absl::Status CdcRsyncServer::HandleSetOptions() {
path::EnsureEndsWithPathSeparator(&copy_dest_);
}
// Expand e.g. ~.
status = path::ExpandPathVariables(&destination_);
if (!status.ok()) {
return WrapStatus(status, "Failed to expand destination '%s'",
destination_);
}
assert(path_filter_.IsEmpty());
for (int n = 0; n < request.filter_rules_size(); ++n) {
std::string fixed_pattern = request.filter_rules(n).pattern();