[content] Fix a buf on ContentTransfer
authorSeokpil Park <seokpil.park@samsung.com>
Fri, 10 May 2013 11:24:48 +0000 (20:24 +0900)
committerSeokpil Park <seokpil.park@samsung.com>
Fri, 10 May 2013 11:24:51 +0000 (20:24 +0900)
Change-Id: I9551cec6d8c73f7b55d5bc2ca1c85030fe1cd488
Signed-off-by: Seokpil Park <seokpil.park@samsung.com>
src/FCnt_ContentTransferImpl.cpp

index 518a3e7..056fac2 100644 (file)
@@ -56,8 +56,7 @@ static const int MAX_DOWNLOAD_COUNT = 5;
 namespace Tizen { namespace Content
 {
 
-static const wchar_t CONTENT_DOWNLOAD_TEMP_DIRECTORY[] = L"/tmp/content/";
-static const wchar_t CONTENT_DOWNLOAD_TEMP_FILE_PATH[] = L"/tmp/content/downloadtempfile";
+static const wchar_t CONTENT_DOWNLOAD_TEMP_DIRECTORY[] = L"/tmp/content_";
 static const wchar_t CONTENT_DOWNLOAD_PATH_MEDIA[] = L"/Media";
 static const wchar_t CONTENT_DOWNLOAD_PATH_MEDIA_MMC[] = L"/Storagecard/Media";
 static const wchar_t CONTENT_DOWNLOAD_PATH_HOME[] = L"/Home";
@@ -198,6 +197,10 @@ _ContentTransferImpl::InitializeEmptySlotInternal(_ContentDownloadUserData* pUse
                        pUserData->SetCheckDownloading(i, false);
                }
 
+               String appId = _AppInfo::GetApplicationId();
+               r = tempPath.Append(appId);
+               SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r, "[E_INVALID_ARG] Failed to perform Append operation.");
+
                // not exist
                check = _FileImpl::IsFileExist(tempPath);
                r = GetLastResult();
@@ -668,7 +671,6 @@ _ContentTransferImpl::DownloadToBuffer(const Utility::Uri& uri, int fileSize, Re
 
        ClearLastResult();
        result r = E_SUCCESS;
-       String tempFilePath(CONTENT_DOWNLOAD_TEMP_FILE_PATH);
        String sourcePath(L"");
        String scheme(L"");
        long long ticks = 0;
@@ -692,6 +694,13 @@ _ContentTransferImpl::DownloadToBuffer(const Utility::Uri& uri, int fileSize, Re
                SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_STATE, E_INVALID_STATE,
                                "[E_INVALID_STATE] Failed to perform GetTicks operation.");
 
+               String tempFilePath(CONTENT_DOWNLOAD_TEMP_DIRECTORY);
+               r = tempFilePath.Append(_AppInfo::GetApplicationId());
+               SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform Append operation.");
+
+               r = tempFilePath.Append(L"/downloadtempfile");
+               SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform Append operation.");
+
                r = tempFilePath.Append(ticks);
                SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_STATE, E_INVALID_STATE,
                                "[E_INVALID_STATE] Failed to append long long type to temporary file path.");
@@ -828,7 +837,6 @@ _ContentTransferImpl::DownloadToBuffer(const Utility::Uri& uri, RequestId& reqId
        ClearLastResult();
        result r = E_SUCCESS;
        String srcFilePath(L"");
-       String tempDestFilePath(CONTENT_DOWNLOAD_TEMP_FILE_PATH);
        String scheme(L"");
        long long ticks = 0;
 
@@ -849,6 +857,13 @@ _ContentTransferImpl::DownloadToBuffer(const Utility::Uri& uri, RequestId& reqId
                r = _SystemTimeImpl::GetTicks(ticks);
                SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to perform GetTicks operation.", GetErrorMessage(r));
 
+               String tempDestFilePath(CONTENT_DOWNLOAD_TEMP_DIRECTORY);
+               r = tempDestFilePath.Append(_AppInfo::GetApplicationId());
+               SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform Append operation.");
+
+               r = tempDestFilePath.Append(L"/downloadtempfile");
+               SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform Append operation.");
+
                r = tempDestFilePath.Append(ticks);
                SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to append long long type to temporary file path.", GetErrorMessage(r));