From efe5c4ae8588d9254cb707896bccfb11a891528e Mon Sep 17 00:00:00 2001 From: Seokpil Park Date: Fri, 12 Jul 2013 17:46:32 +0900 Subject: [PATCH] [content] Fix a bug on CreateContent Change-Id: I61ba5e3a8f558b45e73c902be65476201dc609e1 Signed-off-by: Seokpil Park --- src/FCnt_ContentManagerImpl.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/FCnt_ContentManagerImpl.cpp b/src/FCnt_ContentManagerImpl.cpp index 8011067..f126fbe 100644 --- a/src/FCnt_ContentManagerImpl.cpp +++ b/src/FCnt_ContentManagerImpl.cpp @@ -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) { -- 2.7.4