summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/Manager/InstallerManager.cpp24
-rwxr-xr-xsrc/Manager/InstallerManager.h2
-rwxr-xr-xsrc/Step/UninstallStep.cpp9
-rwxr-xr-xsrc/Util/InstallerUtil.cpp16
-rwxr-xr-xsrc/Util/InstallerUtil.h1
-rwxr-xr-xsrc/backend/backend.cpp8
6 files changed, 40 insertions, 20 deletions
diff --git a/src/Manager/InstallerManager.cpp b/src/Manager/InstallerManager.cpp
index 7c682c8..9f53bcf 100755
--- a/src/Manager/InstallerManager.cpp
+++ b/src/Manager/InstallerManager.cpp
@@ -656,26 +656,20 @@ InstallerManager::ParseCommandArg(int argc, char **argv, int *mode, char *buf, b
}
bool
-InstallerManager::RemoveGarbage(const char* pDirectory)
+InstallerManager::RemoveGarbage(const String& filePath)
{
- char pkgname[1024] = {0};
+ AppLogTag(OSP_INSTALLER, "RemoveGarbage Directory = [%ls]", filePath.GetPointer());
- if (pDirectory == null)
+ String realPath;
+ if (InstallerUtil::IsSymlink(filePath) == true)
{
- return false;
- }
-
- char* pStart = strrchr(const_cast<char*>(pDirectory), '/');
- if (pStart == null)
- {
- return false;
+ if (InstallerUtil::GetRealPath(filePath, realPath) == true)
+ {
+ InstallerUtil::Remove(realPath);
+ }
}
- strcpy(pkgname, pStart + 1);
- AppLogTag(OSP_INSTALLER, "pkgname = %s", pkgname);
-
- AppLogTag(OSP_INSTALLER, "Remove Directory=(%s)", pDirectory);
- InstallerUtil::Remove(pDirectory);
+ InstallerUtil::Remove(filePath);
return true;
}
diff --git a/src/Manager/InstallerManager.h b/src/Manager/InstallerManager.h
index f61dcef..9e4a05f 100755
--- a/src/Manager/InstallerManager.h
+++ b/src/Manager/InstallerManager.h
@@ -47,7 +47,7 @@ public:
int Request(const Osp::Base::String& path, InstallerOperation op, RequesterType requesterType, bool hybridService = false);
int RequestRecursiveDirectory(const Osp::Base::String& path, int& errorType);
- bool RemoveGarbage(const char* pDirectory);
+ bool RemoveGarbage(const Osp::Base::String& filePath);
int RequestByCommand(int argc, char **argv);
int ReqeustByTest(void);
diff --git a/src/Step/UninstallStep.cpp b/src/Step/UninstallStep.cpp
index 1e5f4d2..2b024a4 100755
--- a/src/Step/UninstallStep.cpp
+++ b/src/Step/UninstallStep.cpp
@@ -205,6 +205,15 @@ UninstallStep::OnStateRemoveDir(void)
}
else
{
+ String realPath;
+ if (InstallerUtil::IsSymlink(rootPath) == true)
+ {
+ if (InstallerUtil::GetRealPath(rootPath, realPath) == true)
+ {
+ InstallerUtil::Remove(realPath);
+ }
+ }
+
InstallerUtil::Remove(rootPath);
}
diff --git a/src/Util/InstallerUtil.cpp b/src/Util/InstallerUtil.cpp
index ef67d72..36fa0cf 100755
--- a/src/Util/InstallerUtil.cpp
+++ b/src/Util/InstallerUtil.cpp
@@ -188,6 +188,22 @@ InstallerUtil::IsSymlink(const Osp::Base::String& filePath)
}
bool
+InstallerUtil::GetRealPath(const String& filePath, String& realPath)
+{
+ char* pRealPath = null;
+ std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
+ TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
+
+ char tmpPath[PATH_MAX] = {0};
+ pRealPath = realpath(pFilePath.get(), tmpPath);
+ TryReturn(pRealPath, false, "[osp-installer] pRealPath is null");
+
+ realPath = tmpPath;
+
+ return true;
+}
+
+bool
InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath)
{
int err = -1;
diff --git a/src/Util/InstallerUtil.h b/src/Util/InstallerUtil.h
index 0386ae5..2fae278 100755
--- a/src/Util/InstallerUtil.h
+++ b/src/Util/InstallerUtil.h
@@ -48,6 +48,7 @@ public:
static bool Copy(const Osp::Base::String& srcFilePath, const Osp::Base::String& destFilePath);
static bool CopyDirectory(const Osp::Base::String& srcFilePath, const Osp::Base::String& destFilePath);
static bool IsSymlink(const Osp::Base::String& filePath);
+ static bool GetRealPath(const Osp::Base::String& filePath, Osp::Base::String& realPath);
static bool CreateSymlink(const Osp::Base::String& oldPath, const Osp::Base::String& newPath);
static bool ChangeMode(const Osp::Base::String& filePath, int mode);
diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp
index 320d505..b72cdff 100755
--- a/src/backend/backend.cpp
+++ b/src/backend/backend.cpp
@@ -109,10 +109,10 @@ main(int argc, char **argv)
AppLogTag(OSP_INSTALLER, "_pi is null");
}
- if (errorType != 0)
- {
- manager.RemoveGarbage(pkg_path);
- }
+// if (errorType != 0)
+// {
+// manager.RemoveGarbage(path);
+// }
__osp_installer_report_result(appId, errorType);
manager.PrintResult();