#include <widget_install/widget_install_errors.h>
#include <widget_install/job_widget_install.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/exception.h>
#include <dpl/errno_string.h>
AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
AddStep(&TaskUpdateFiles::StepExecFileBackup);
- AddStep(&TaskUpdateFiles::StepUpdateExternalFiles);
AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
}
}
-void TaskUpdateFiles::StepUpdateExternalFiles()
-{
- WidgetDAO dao(m_context.locations->getPkgname());
- WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
- WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
- LogDebug("Removing external files:");
- FOREACH(file, externalLocationsDB)
- {
- if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
- {
- if(WrtUtilFileExists(*file))
- {
- LogDebug(" -> " << *file);
- remove(file->c_str());
- }
- else if(WrtUtilDirExists(*file))
- {
- LogDebug(" -> " << *file);
- if(!WrtUtilRemove(*file)){
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Failed to remove external directory");
- }
- }
- else
- {
- LogWarning(" -> " << *file << "(no such a path)");
- }
- }
- }
- dao.unregisterAllExternalLocations();
- LogDebug("Registering(update) external files:");
- FOREACH(file, externalLocationsUpdate)
- {
- LogDebug(" -> " << *file);
- }
- dao.registerExternalLocations(externalLocationsUpdate);
-}
-
} //namespace WidgetInstall
} //namespace Jobs