namespace common_installer {
namespace recovery {
-std::unique_ptr<RecoveryFile> RecoveryFile::CreateRecoveryFileForPath(
- const boost::filesystem::path& path) {
+std::unique_ptr<RecoveryFile> RecoveryFile::CreateRecoveryFile(
+ const boost::filesystem::path& path, RequestType type) {
if (bf::exists(path)) {
LOG(ERROR) << "Recovery file already exists!";
return nullptr;
}
- std::unique_ptr<RecoveryFile> file(new RecoveryFile(path, false));
+ std::unique_ptr<RecoveryFile> file(new RecoveryFile(path, type, false));
if (file->is_detached()) {
LOG(ERROR) << "Failed to access file";
return nullptr;
return file;
}
-std::unique_ptr<RecoveryFile> RecoveryFile::OpenRecoveryFileForPath(
+std::unique_ptr<RecoveryFile> RecoveryFile::OpenRecoveryFile(
const boost::filesystem::path& path) {
if (!bf::exists(path)) {
LOG(ERROR) << "Cannot open recovery file";
return nullptr;
}
- std::unique_ptr<RecoveryFile> file(new RecoveryFile(path, true));
+ std::unique_ptr<RecoveryFile> file(new RecoveryFile(path,
+ RequestType::Unknown, true));
if (file->is_detached()) {
LOG(ERROR) << "Failed to read recovery file";
return nullptr;
return file;
}
-RecoveryFile::RecoveryFile(const bf::path& path, bool load)
- : type_(RequestType::Unknown), path_(path) {
+RecoveryFile::RecoveryFile(const bf::path& path, RequestType type, bool load)
+ : type_(type), path_(path) {
if (load) {
if (!ReadFileContent()) {
path_.clear();
*
* \return new RecoveryFile object
*/
- static std::unique_ptr<RecoveryFile> CreateRecoveryFileForPath(
- const boost::filesystem::path& path);
+ static std::unique_ptr<RecoveryFile> CreateRecoveryFile(
+ const boost::filesystem::path& path, RequestType type);
/**
* Opens RecoveryFile object for given request
*
* \return new RecoveryFile object
*/
- static std::unique_ptr<RecoveryFile> OpenRecoveryFileForPath(
+ static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
const boost::filesystem::path& path);
/** Desctructor */
bool WriteAndCommitFileContent();
private:
- RecoveryFile(const boost::filesystem::path& path, bool load);
+ RecoveryFile(const boost::filesystem::path& path, RequestType type,
+ bool load);
bool ReadFileContent();
requestType == RequestType::MountInstall ||
requestType == RequestType::MountUpdate) {
std::unique_ptr<recovery::RecoveryFile> recovery_file =
- recovery::RecoveryFile::CreateRecoveryFileForPath(
+ recovery::RecoveryFile::CreateRecoveryFile(
GenerateTemporaryPath(
context_->root_application_path.get() /
- (context_->pkg_type.get() + "-recovery")));
+ (context_->pkg_type.get() + "-recovery")),
+ requestType);
if (!recovery_file) {
LOG(ERROR) << "Failed to create recovery file";
return Status::CONFIG_ERROR;
Step::Status StepOpenRecoveryFile::process() {
std::unique_ptr<recovery::RecoveryFile> recovery_file =
- RecoveryFile::OpenRecoveryFileForPath(context_->file_path.get());
+ RecoveryFile::OpenRecoveryFile(context_->file_path.get());
if (!recovery_file) {
LOG(ERROR) << "Failed to open recovery file";
return Status::RECOVERY_ERROR;