namespace filesystem {
Step::Status StepRecoverManifest::RecoveryNew() {
- if (!SetXmlPaths()) {
+ if (!SetXmlPaths(context_->is_readonly_package.get())) {
LOG(DEBUG) << "Manifest recovery not needed";
return Status::OK;
}
}
Step::Status StepRecoverManifest::RecoveryUpdate() {
- if (!SetXmlPaths()) {
+ if (!SetXmlPaths(context_->is_readonly_package.get())) {
LOG(DEBUG) << "Manifest recovery not needed";
return Status::OK;
}
return Status::OK;
}
+Step::Status StepRecoverManifest::RecoveryReadonlyUpdateInstall() {
+ if (!SetXmlPaths(false)) {
+ LOG(DEBUG) << "Manifest recovery not needed";
+ return Status::OK;
+ }
+ if (bf::exists(context_->xml_path.get())) {
+ if (!Remove(context_->xml_path.get())) {
+ LOG(ERROR) << "Cannot move manifest file to restore its location";
+ return Status::RECOVERY_ERROR;
+ }
+ }
+ LOG(INFO) << "Manifest recovery done";
+ return Status::OK;
+}
+
Step::Status StepRecoverManifest::Cleanup() {
- if (!SetXmlPaths()) {
+ if (!SetXmlPaths(context_->is_readonly_package.get())) {
LOG(DEBUG) << "Manifest recovery not needed";
return Status::OK;
}
return Status::OK;
}
-bool StepRecoverManifest::SetXmlPaths() {
+bool StepRecoverManifest::SetXmlPaths(bool is_readonly_package) {
if (context_->pkgid.get().empty())
return false;
bf::path xml_path =
- bf::path(getUserManifestPath(context_->uid.get(),
- context_->is_readonly_package.get()))
+ bf::path(getUserManifestPath(context_->uid.get(), is_readonly_package))
/ context_->pkgid.get();
xml_path += ".xml";
context_->xml_path.set(xml_path);
Status RecoveryNew() override;
Status RecoveryUpdate() override;
+ Status RecoveryReadonlyUpdateInstall() override;
Status Cleanup() override;
private:
- bool SetXmlPaths();
+ bool SetXmlPaths(bool is_readonly_package);
STEP_NAME(RecoverManifest)
};