2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file task_recovery.cpp
18 * @author Soyoung Kim (sy037.kim@samsung.com)
20 * @brief Implementation file for installer task recovery
22 #include "task_recovery.h"
27 #include <sys/types.h>
32 #include <dpl/log/log.h>
33 #include <dpl/errno_string.h>
34 #include <dpl/foreach.h>
36 #include <dpl/wrt-dao-ro/widget_config.h>
37 #include <dpl/utils/file_utils.h>
38 #include <dpl/utils/wrt_utility.h>
39 #include <widget_install/job_widget_install.h>
40 #include <widget_install/widget_install_context.h>
41 #include <widget_install/widget_install_errors.h>
43 using namespace WrtDB;
46 namespace WidgetInstall {
47 TaskRecovery::TaskRecovery(InstallerContext& context) :
48 DPL::TaskDecl<TaskRecovery>(this),
51 AddStep(&TaskRecovery::StepCreateCheckFile);
54 void TaskRecovery::StepCreateCheckFile()
56 LogInfo("Step: create information file for recovery");
58 size_t pos = m_context.locations->getWidgetSource().rfind("/");
59 std::ostringstream infoPath;
60 infoPath << GlobalConfig::GetTempInstallInfoPath();
62 infoPath << m_context.locations->getWidgetSource().substr(pos+1);
64 FILE *temp = fopen(infoPath.str().c_str(), "w+");
66 fputs(m_context.locations->getWidgetSource().c_str(), temp);
70 m_context.installInfo = infoPath.str();
72 LogDebug("Create file : " << m_context.installInfo);
73 m_context.job->UpdateProgress(
74 InstallerContext::INSTALL_LINK_DEPENDS_DIRECTORY,
75 "depends directory linked."
78 ThrowMsg(Exceptions::InternalError, "Fail to create file for recovery.");
81 m_context.job->SetProgressFlag(true);
82 m_context.job->UpdateProgress(
83 InstallerContext::INSTALL_CHECK_FILE,
84 "Create information file for recovery");
86 } //namespace WidgetInstall