namespace bf = boost::filesystem;
namespace bs = boost::system;
+namespace ci = common_installer;
namespace common_installer {
namespace backup {
}
Step::Status StepBackupManifest::clean() {
- bs::error_code error;
- bf::remove(context_->backup_xml_path.get(), error);
- if (error) {
- LOG(WARNING) << "Cannot remove backup manifest file";
- return Status::MANIFEST_ERROR;
- }
- LOG(DEBUG) << "Manifest backup removed";
+ LOG(DEBUG) << "Remove manifest backup";
+ ci::Remove(context_->backup_xml_path.get());
return Status::OK;
}
recovery_file->set_cleanup(true);
recovery_file->WriteAndCommitFileContent();
- if (!CleanBackupDirectory()) {
- LOG(DEBUG) << "Cannot remove backup directory";
- return Status::APP_DIR_ERROR;
- }
- LOG(DEBUG) << "Applications files backup directory removed";
+ LOG(DEBUG) << "Remove Applications files backup directory";
+ CleanBackupDirectory();
if (context_->external_storage)
context_->external_storage->Commit();
}
bool StepCopyBackup::CleanBackupDirectory() {
- if (bf::exists(backup_path_)) {
- bs::error_code error;
- bf::remove_all(backup_path_, error);
- if (error)
- return false;
- }
- return true;
+ return ci::RemoveAll(backup_path_);
}
bool StepCopyBackup::RollbackApplicationDirectory() {
if (mode_ == UpdateMode::NONE)
return Status::OK;
- if (context_->request_mode.get() == RequestMode::GLOBAL) {
- if (!CleanUpdatePerUserStorageDirectories())
- return Status::APP_DIR_ERROR;
- } else {
- if (!CleanUpdateStorageDirectories())
- return Status::APP_DIR_ERROR;
- }
+ if (context_->request_mode.get() == RequestMode::GLOBAL)
+ CleanUpdatePerUserStorageDirectories();
+ else
+ CleanUpdateStorageDirectories();
return Status::OK;
}
strcmp(context_->old_manifest_data.get()->tep_name,
context_->manifest_data.get()->tep_name)) {
bf::path old_tep = context_->old_manifest_data.get()->tep_name;
- bs::error_code error;
- bf::remove(old_tep, error);
- if (error) {
- LOG(WARNING) << "Failed to cleanup old tep package from sd card";
- }
+ Remove(old_tep);
}
}
return Status::OK;
}
Step::Status StepMountInstall::clean() {
- return UmountPackagePath();
+ UmountPackagePath();
+
+ return Status::OK;
}
Step::Status StepMountInstall::undo() {
return Status::OK;
}
-Step::Status StepMountUpdate::clean() {
- bf::path backup_zip_location =
- GetBackupPathForZipFile(GetZipPackageLocation(
- context_->GetPkgPath(), context_->pkgid.get()));
- bs::error_code error;
- bf::remove(backup_zip_location, error);
-
+Step::Status StepMountUpdate::UmountPackagePath() {
bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
return Status::APP_DIR_ERROR;
}
+
+ return Status::OK;
+}
+
+Step::Status StepMountUpdate::clean() {
+ bf::path backup_zip_location =
+ GetBackupPathForZipFile(GetZipPackageLocation(
+ context_->GetPkgPath(), context_->pkgid.get()));
+ Remove(backup_zip_location);
+
+ UmountPackagePath();
+
return Status::OK;
}
Step::Status StepMountUpdate::undo() {
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
- TzipInterface tzip_final(mount_point);
- if (!tzip_final.UnmountZip()) {
- LOG(ERROR) << "Failed to unmount zip package after installation";
- return Status::APP_DIR_ERROR;
- }
+ UmountPackagePath();
bf::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
}
// mount previous file for re-registration of trust anchor
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ TzipInterface tzip_final(mount_point);
bf::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
if (!tzip_final.MountZip(zip_destination_path)) {
Status undo() override;
Status precheck() override;
+ protected:
+ Status UmountPackagePath();
+
STEP_NAME(MountUpdate)
};
} else {
manifest_path = context_->xml_path.get();
}
- bs::error_code error;
- bf::remove(manifest_path, error);
- if (error) {
- LOG(ERROR) << "Failed to remove xml manifest file";
- return Status::MANIFEST_ERROR;
- }
- LOG(DEBUG) << "Manifest file removed";
+ LOG(DEBUG) << "Remove manifest file";
+ Remove(manifest_path);
return Status::OK;
}
}
Step::Status StepRunParserPlugin::clean() {
- if (!ProcessPlugins(context_->xml_path.get(),
- context_->manifest_data.get(),
- Plugin::ActionType::Clean))
- return Status::ERROR;
+ ProcessPlugins(context_->xml_path.get(),
+ context_->manifest_data.get(),
+ Plugin::ActionType::Clean);
+
return Status::OK;
}
LOG(ERROR) << "error_message: " << error_message;
on_error(Status::SECURITY_ERROR, error_message);
}
- return Status::SECURITY_ERROR;
+ } else {
+ LOG(DEBUG) << "Security context uninstalled";
}
- LOG(DEBUG) << "Security context uninstalled";
return Status::OK;
}
#include <string>
#include "common/certificate_validation.h"
+#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
namespace ci = common_installer;
}
Step::Status StepSignature::clean() {
- if (bf::exists(signature_->GetBackupPath()))
- bf::remove(signature_->GetBackupPath());
+ Remove(signature_->GetBackupPath());
return Step::Status::OK;
}