#include <string>
#include "common/paths.h"
+#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
-#include "common/shared_dirs.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
const char kExternalMemoryMountPoint[] = ".mmc";
const char kSharedResPath[] = "shared/res";
+const char kCachePath[] = "cache";
+const char kDataPath[] = "data";
+const char kSharedDataPath[] = "shared/data";
bool CheckFreeSpace(const bf::path& backup_path, const bf::path& shared_path) {
int64_t shared_size = ci::GetDirectorySize(shared_path);
}
}
+void StepCopyBackup::RemoveRWDirectories() {
+ if (!RemoveAll(context_->unpacked_dir_path.get() / kCachePath))
+ LOG(ERROR) << "Failed to remove packaged cache directory";
+ if (!RemoveAll(context_->unpacked_dir_path.get() / kDataPath))
+ LOG(ERROR) << "Failed to remove packaged data directory";
+ if (!RemoveAll(context_->unpacked_dir_path.get() / kSharedDataPath))
+ LOG(ERROR) << "Failed to remove packaged shared/data directory";
+}
+
bool StepCopyBackup::NewContent() {
+ RemoveRWDirectories();
+
bs::error_code error;
bf::create_directories(install_path_.parent_path(), error);
if (error) {
bool RollbackApplicationDirectory();
bool MoveMountPointContent(const boost::filesystem::path& from,
const boost::filesystem::path& to);
+ void RemoveRWDirectories();
boost::filesystem::path install_path_;
boost::filesystem::path backup_path_;
#include <cstring>
#include <string>
+#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
-namespace common_installer {
-namespace filesystem {
-
namespace bf = boost::filesystem;
namespace bs = boost::system;
+namespace ci = common_installer;
+
+namespace {
+
+const char kCachePath[] = "cache";
+const char kDataPath[] = "data";
+const char kSharedDataPath[] = "shared/data";
+
+} // namespace
+
+namespace common_installer {
+namespace filesystem {
Step::Status StepCopy::precheck() {
if (context_->root_application_path.get().empty()) {
return Step::Status::OK;
}
+void StepCopy::RemoveRWDirectories() {
+ if (!RemoveAll(context_->unpacked_dir_path.get() / kCachePath))
+ LOG(ERROR) << "Failed to remove packaged cache directory";
+ if (!RemoveAll(context_->unpacked_dir_path.get() / kDataPath))
+ LOG(ERROR) << "Failed to remove packaged data directory";
+ if (!RemoveAll(context_->unpacked_dir_path.get() / kSharedDataPath))
+ LOG(ERROR) << "Failed to remove packaged shared/data directory";
+}
+
+
Step::Status StepCopy::process() {
bf::path install_path;
if (context_->storage.get() == Storage::EXTENDED) {
install_path = context_->GetPkgPath();
}
+ RemoveRWDirectories();
+
bs::error_code error;
bf::create_directories(install_path.parent_path(), error);
if (error) {
*/
Status precheck() override;
+ private:
+ void RemoveRWDirectories();
+
STEP_NAME(Copy)
};