* Applies the changes from the new catalog onto the repository. * * Let: * + C_O = the root catalog of the repository (given by old_root_hash) at * the beginning of the lease, on the release manager machine * + C_N = the root catalog of the repository (given by new_root_hash), on * the release manager machine, with the changes introduced during the * lease
| 192 | * repository manifest. |
| 193 | */ |
| 194 | CommitProcessor::Result CommitProcessor::Process( |
| 195 | const std::string &lease_path, const shash::Any &old_root_hash, |
| 196 | const shash::Any &new_root_hash, const RepositoryTag &tag, |
| 197 | int64_t lease_expiration, uint64_t *final_revision, bool direct_graft) { |
| 198 | RepositoryTag final_tag = tag; |
| 199 | // If tag_name is a generic tag, update the time stamp |
| 200 | if (final_tag.HasGenericName()) { |
| 201 | final_tag.SetGenericName(); |
| 202 | } |
| 203 | |
| 204 | LogCvmfs(kLogReceiver, kLogSyslog, |
| 205 | "CommitProcessor - lease_path: %s, old hash: %s, new hash: %s, " |
| 206 | "tag_name: %s, tag_description: %s", |
| 207 | lease_path.c_str(), old_root_hash.ToString(true).c_str(), |
| 208 | new_root_hash.ToString(true).c_str(), final_tag.name().c_str(), |
| 209 | final_tag.description().c_str()); |
| 210 | |
| 211 | const std::vector<std::string> lease_path_tokens = SplitString(lease_path, |
| 212 | '/'); |
| 213 | |
| 214 | const std::string repo_name = lease_path_tokens.front(); |
| 215 | |
| 216 | Params params; |
| 217 | if (!GetParamsFromFile(repo_name, ¶ms)) { |
| 218 | LogCvmfs( |
| 219 | kLogReceiver, kLogSyslogErr, |
| 220 | "CommitProcessor - error: Could not get configuration parameters."); |
| 221 | return kError; |
| 222 | } |
| 223 | |
| 224 | const UniquePtr<ServerTool> server_tool(new ServerTool()); |
| 225 | |
| 226 | if (!server_tool->InitDownloadManager(true, params.proxy)) { |
| 227 | LogCvmfs( |
| 228 | kLogReceiver, kLogSyslogErr, |
| 229 | "CommitProcessor - error: Could not initialize the download manager"); |
| 230 | return kError; |
| 231 | } |
| 232 | |
| 233 | const std::string public_key = "/etc/cvmfs/keys/" + repo_name + ".pub"; |
| 234 | const std::string certificate = "/etc/cvmfs/keys/" + repo_name + ".crt"; |
| 235 | const std::string private_key = "/etc/cvmfs/keys/" + repo_name + ".key"; |
| 236 | if (!server_tool->InitSignatureManager(public_key, certificate, |
| 237 | private_key)) { |
| 238 | LogCvmfs( |
| 239 | kLogReceiver, kLogSyslogErr, |
| 240 | "CommitProcessor - error: Could not initialize the signature manager"); |
| 241 | return kError; |
| 242 | } |
| 243 | |
| 244 | const shash::Any manifest_base_hash; |
| 245 | const UniquePtr<manifest::Manifest> manifest_tgt( |
| 246 | server_tool->FetchRemoteManifest(params.stratum0, repo_name, |
| 247 | manifest_base_hash)); |
| 248 | |
| 249 | // Current catalog from the gateway machine |
| 250 | if (!manifest_tgt.IsValid()) { |
| 251 | LogCvmfs(kLogReceiver, kLogSyslogErr, |
no test coverage detected