1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef COMMON_RECOVERY_FILE_H_
6 #define COMMON_RECOVERY_FILE_H_
13 #include "common/utils/request.h"
15 namespace common_installer {
20 * Responsible for managing recovery file.
22 * It dumps information to recover file regarding current status of handled
28 * Creates new RecoveryFile object for given file
30 * \param path path to the package/id
32 * \return new RecoveryFile object
34 static std::unique_ptr<RecoveryFile> CreateRecoveryFile(
35 const std::filesystem::path& path, RequestType type);
38 * Opens RecoveryFile object for given request
40 * \param path path to the package/id
42 * \return new RecoveryFile object
44 static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
45 const std::filesystem::path& path);
50 /** Detaching object from given recovery file */
54 * Checks if object is detached from file
56 * \return true if detached
59 bool is_detached() const;
62 * setter for unpacked dir
64 * \param unpacked_dir new unpacked_dir value
66 void set_unpacked_dir(std::filesystem::path unpacked_dir);
71 * \param pkgid new pkgid value
73 void set_pkgid(std::string pkgid);
76 * setter for backup done
78 * \param backup_done boolean value of backup_done
80 void set_backup_done(bool backup_done);
83 * setter for cleanup flag
85 * \param cleanup boolean value of cleanup
87 void set_cleanup(bool cleanup);
90 * setter for security operation done
92 * \param security_operation_done boolean value of security_operation_done
94 void set_security_operation_done(bool security_operation_done);
97 * getter for unpacked dir
99 * \return current unpacked_dir
101 const std::filesystem::path& unpacked_dir() const;
106 * * \return current pkgid
108 const std::string& pkgid() const;
111 * getter for request type
113 * \return current request type
115 RequestType type() const;
118 * getter for backup exist flag
120 * \return true if backup does exist
122 bool backup_done() const;
125 * getter for cleanup flag
127 * \return true if cleanup flag has set
129 bool cleanup() const;
132 * getter for security operation done flag
134 * \return true if security operation done flag has set
136 bool security_operation_done() const;
139 * Transaction of current RecoveryFile content into recovery file
141 * \return true if success
143 bool WriteAndCommitFileContent();
146 RecoveryFile(const std::filesystem::path& path, RequestType type,
149 bool ReadFileContent();
152 std::filesystem::path unpacked_dir_;
155 std::filesystem::path path_;
156 std::filesystem::path backup_path_;
159 bool security_operation_done_;
162 } // namespace recovery
163 } // namespace common_installer
165 #endif // COMMON_RECOVERY_FILE_H_