Integrate recovery file creation and first write procedure 04/162304/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Nov 2017 07:27:39 +0000 (16:27 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Nov 2017 07:27:39 +0000 (16:27 +0900)
- Recovery file creation process is separated with
  file creation and type write processes.
- Integrate those two processes into one.

Change-Id: I9c5e0b192c8f35d7a612e58417bed1d9468bfd87
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/recovery_file.cc
src/common/step/recovery/step_create_recovery_file.cc

index af8f55e78052bcf2eb59f34162cffb669113c6fb..966c06f22bb965fe3c4d03651601b0ccd0aee8ab 100644 (file)
@@ -92,12 +92,10 @@ RecoveryFile::RecoveryFile(const bf::path& path, RequestType type, bool load)
     }
   } else {
     // create file
-    FILE* handle = fopen(path.c_str(), "w");
-    if (!handle) {
+    if (!WriteAndCommitFileContent()) {
       path_.clear();
       return;
     }
-    fclose(handle);
     LOG(DEBUG) << "Recovery file " << path_ << " created";
   }
 }
index e743537c3ce203411ccfc8f442b4c4e165191ae3..51d89c3f7f916e57e16a6ebe3fc6cd66601449e4 100644 (file)
@@ -38,12 +38,6 @@ Step::Status StepCreateRecoveryFile::process() {
     LOG(ERROR) << "Failed to create recovery file";
     return Status::CONFIG_ERROR;
   }
-  recovery_file->set_type(context_->request_type.get());
-
-  if (!recovery_file->WriteAndCommitFileContent()) {
-    LOG(ERROR) << "Failed to write recovery file";
-    return Status::CONFIG_ERROR;
-  }
   context_->recovery_info.set(RecoveryInfo(std::move(recovery_file)));
 
   return Status::OK;