#include <cstring>
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
// preserve old tep path if no new tep is supplied
if (context_->tep_path.get().empty() &&
context_->old_manifest_data.get()->tep_name) {
+ if (context_->manifest_data.get()->tep_name)
+ free(context_->manifest_data.get()->tep_name);
context_->manifest_data.get()->tep_name =
strdup(context_->old_manifest_data.get()->tep_name);
bf::path new_path = context_->manifest_data.get()->tep_name;
bf::path backup_path =
GetInternalTepPath(
- GetBackupPathForPackagePath(context_->pkg_path.get()));
+ GetBackupPathForPackagePath(context_->GetPkgPath()));
backup_path /= new_path.filename();
if (!bf::exists(new_path.parent_path())) {
bs::error_code error;
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 StepUpdateTep::undo() {
- bs::error_code error;
- if (bf::exists(context_->tep_path.get())) {
- bf::remove_all(context_->tep_path.get(), error);
- }
+ const bf::path& remove_path = context_->tep_path.get();
+ RemoveAll(context_->old_manifest_data.get()->tep_name ?
+ remove_path : remove_path.parent_path());
return Status::OK;
}