#include <sys/stat.h>
#include <string>
#include <sstream>
-#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/foreach.h>
#include <dpl/log/log.h>
DPL::TaskDecl<TaskRemoveBackupFiles>(this),
m_context(context)
{
- AddStep(&TaskRemoveBackupFiles::StepDeleteDB);
AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
}
-void TaskRemoveBackupFiles::StepDeleteDB()
-{
- LogInfo("Delete old widget DB");
- Try
- {
- // If there is existing model, remove its database data
- if (true == m_context.existingWidgetInfo.isExist) {
- WidgetHandle old = m_context.existingWidgetInfo.existingHandle;
- LogInfo("Unregistering widget...: " << old);
- WidgetDAO::unregisterWidget(old);
- LogInfo("Widget unregistered");
- }
- }
- Catch(DPL::DB::SqlConnection::Exception::Base)
- {
- LogError("Failed to clean up old widget DB!");
- ReThrowMsg(Exceptions::RemoveBackupFailed, "Database failure!");
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_DELETE_OLD_DB,
- "Backup widget db delete Finished");
-}
-
void TaskRemoveBackupFiles::StepRemoveBackupFiles()
{
std::ostringstream backupDir;
backupDir << m_context.locations->getBackupDir();
- if (_WrtUtilRemoveDir(backupDir.str().c_str())) {
+ if (WrtUtilRemove(backupDir.str())) {
LogDebug("Success to remove backup files : " << backupDir.str());
} else {
- LogDebug("Failed to remove backup directory : " << backupDir.str());
+ LogError("Failed to remove backup directory : " << backupDir.str());
ThrowMsg(Exceptions::RemoveBackupFailed,
"Error occurs during removing existing folder");
}
std::string tmp = m_context.locations->getTemporaryPackageDir();
- if (_WrtUtilRemoveDir(tmp.c_str())) {
+ if (WrtUtilRemove(tmp)) {
LogDebug("Success to remove temp directory : " << tmp);
} else {
- LogDebug("Failed to remove temp directory : " << tmp);
+ LogError("Failed to remove temp directory : " << tmp);
ThrowMsg(Exceptions::RemoveBackupFailed,
"Error occurs during removing existing folder");
}