}
RecoveryFile::RecoveryFile(const bf::path& path, RequestType type, bool load)
- : type_(type), path_(path), backup_done_(false), cleanup_(false) {
+ : type_(type), path_(path), backup_done_(false), cleanup_(false),
+ security_operation_done_(false) {
backup_path_ = path_.string() + ".bck";
if (load) {
if (!ReadFileContent()) {
cleanup_ = cleanup;
}
+void RecoveryFile::set_security_operation_done(bool security_operation_done) {
+ security_operation_done_ = security_operation_done;
+}
+
const boost::filesystem::path& RecoveryFile::unpacked_dir() const {
return unpacked_dir_;
}
return cleanup_;
}
+bool RecoveryFile::security_operation_done() const {
+ return security_operation_done_;
+}
+
bool RecoveryFile::ReadFileContent() {
FILE* handle = fopen(path_.c_str(), "r");
if (!handle) {
cleanup_ = true;
else
cleanup_ = false;
+ if (!fgets(data.data(), data.size(), handle)) {
+ fclose(handle);
+ return true;
+ }
+ std::string security_operation_done_flag = TruncateNewLine(data.data());
+ if (security_operation_done_flag == "true")
+ security_operation_done_ = true;
+ else
+ security_operation_done_ = false;
fclose(handle);
return true;
}
ofs << pkgid_ << std::endl;
ofs << (backup_done_ ? "true" : "false") << std::endl;
ofs << (cleanup_ ? "cleanup" : "rollback") << std::endl;
+ ofs << (security_operation_done_ ? "true" : "false") << std::endl;
ofs.flush();
::fsync(ofs->handle());
ofs.close();