Remove shared/trusted directory when update case.
Make util function to remove rw directories.
Change-Id: Ide197cbcd97a4e6faf7faf1941880a50abf711fb
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
return true;
}
-bool DeleteStorageDirectories(const boost::filesystem::path& path,
- const std::string& pkgid) {
- std::vector<const char*> dirs;
- dirs.assign(kEntries.begin() + 1, kEntries.end());
- dirs.push_back(kSharedTrustedDir);
- dirs.push_back(kSharedCacheDir);
- for (auto& entry : dirs) {
- bf::path subpath = path / pkgid / entry;
- if (!ci::RemoveAll(subpath))
- return false;
- }
- if (!DeleteSharedDataDirectories(path, pkgid))
- return false;
-
- return true;
+void RemoveRWDirectories(const boost::filesystem::path& root) {
+ if (!RemoveAll(root / kCache))
+ LOG(ERROR) << "Failed to remove packaged cache directory";
+ if (!RemoveAll(root / kData))
+ LOG(ERROR) << "Failed to remove packaged data directory";
+ if (!RemoveAll(root / kSharedCacheDir))
+ LOG(ERROR) << "Failed to remove packaged shared/cache directory";
+ if (!RemoveAll(root / kSharedDataDir))
+ LOG(ERROR) << "Failed to remove packaged shared/data directory";
+ if (!RemoveAll(root / kSharedTrustedDir))
+ LOG(ERROR) << "Failed to remove packaged shared/trusted directory";
}
bool DeleteSharedDirectories(const bf::path& path,
bool keep_rwdata = false);
/**
- * \brief Deletes storage directories in path
+ * \brief Deletes RW directories in path, this should be invoked after
+ * unzipping package for remove rw directories
*
- * \param path base path, which contains storage directories
- * \param pkgid package id
- *
- * \return true if succeed, false otherwise
+ * \param path base path, which contains rw directories
*/
-bool DeleteStorageDirectories(const boost::filesystem::path& path,
- const std::string& pkgid);
+void RemoveRWDirectories(const boost::filesystem::path& root);
/**
* \brief Deletes shared directories in path
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();
+ ci::RemoveRWDirectories(context_->unpacked_dir_path.get());
bs::error_code error;
bf::create_directories(install_path_.parent_path(), 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_;
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 {
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();
+ ci::RemoveRWDirectories(context_->unpacked_dir_path.get());
bs::error_code error;
bf::create_directories(install_path.parent_path(), error);
Status precheck() override;
private:
- void RemoveRWDirectories();
-
STEP_NAME(Copy)
};
LOG(INFO) << "Creating per-user directories for package: "
<< context_->pkgid.get();
- RequestType req_type = context_->request_type.get();
- if (req_type != RequestType::ManifestPartialInstall &&
- req_type != RequestType::ManifestDirectInstall) {
- // remove packaged RW diriectories
- if (!DeleteStorageDirectories(context_->root_application_path.get(),
- context_->pkgid.get())) {
- LOG(ERROR) << "Failed to remove storage directories";
- return false;
- }
- }
-
bool is_readonly = context_->is_readonly_package.get();
if (!CreatePerUserStorageDirectories(context_->pkgid.get(), trusted,
shareddata, is_readonly, additional_shared_dirs_)) {
#include <string>
+#include "common/shared_dirs.h"
#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
+namespace ci = common_installer;
namespace common_installer {
namespace mount {
if (!CopyFile(context_->file_path.get(), zip_destination_path)) {
return Status::APP_DIR_ERROR;
}
+ ci::RemoveRWDirectories(zip_destination_path);
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());
#include <string>
+#include "common/shared_dirs.h"
#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
+namespace ci = common_installer;
namespace common_installer {
namespace mount {
if (!CopyFile(context_->file_path.get(), zip_destination_path)) {
return Status::APP_DIR_ERROR;
}
+ ci::RemoveRWDirectories(zip_destination_path);
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());