[content] Fix a bug on CreateContent
authorSeokpil Park <seokpil.park@samsung.com>
Fri, 12 Jul 2013 08:46:32 +0000 (17:46 +0900)
committerSeokpil Park <seokpil.park@samsung.com>
Fri, 12 Jul 2013 08:46:39 +0000 (17:46 +0900)
Change-Id: I61ba5e3a8f558b45e73c902be65476201dc609e1
Signed-off-by: Seokpil Park <seokpil.park@samsung.com>
src/FCnt_ContentManagerImpl.cpp

index 8011067..f126fbe 100644 (file)
@@ -534,6 +534,7 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                        E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
 
        result r = E_SUCCESS;
+       bool isCopy = false;
 
        if (deleteSource) // move
        {
@@ -546,6 +547,8 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                //  Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
                r = _FileImpl::Copy(sourcePath, destinationPath, true);
                SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
+
+               isCopy = true;
        }
 
        int val = 0;
@@ -610,9 +613,16 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
 CATCH:
        result saveResult = GetLastResult();
 
-       // If the destination file is made by this method, it should be deleted when error occurs.
-       r = _FileImpl::Remove(destinationPath);
-       SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
+       if (isCopy)
+       {
+               r = _FileImpl::Remove(destinationPath);
+               SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
+       }
+       else
+       {
+               r = _FileImpl::Move(destinationPath, sourcePath);
+               SysLog(NID_CNT, "Move[%s].", GetErrorMessage(r));
+       }
 
        if (pMediaInfo != null)
        {