[Filesystem] Make directory does not throw if dir already exists
authorWojciech Kosowicz <w.kosowicz@samsung.com>
Mon, 2 Mar 2015 09:34:42 +0000 (10:34 +0100)
committerRafal Galka <r.galka@samsung.com>
Tue, 3 Mar 2015 13:26:57 +0000 (22:26 +0900)
This issue was causing many testcases fail in tct. In case the dir
already existed we should not throw as the method goes recursively
so some dirs might already exist

Change-Id: I6e7b30857e6204ad9d9617e6a49f0222385989dd
Signed-off-by: Wojciech Kosowicz <w.kosowicz@samsung.com>
src/filesystem/filesystem_instance.cc

index 6757b562a24355c1c0d4fd95c4a7ec33488692ae..059e37b35793a8977d0b7dcd81d76c18aa53f8cc 100644 (file)
@@ -396,7 +396,10 @@ void FilesystemInstance::FileSystemManagerMakeDirectory(
     picojson::value response = picojson::value(picojson::object());
     picojson::object& obj = response.get<picojson::object>();
     obj["callbackId"] = picojson::value(callback_id);
-    PrepareError(e, obj);
+    if (e == FilesystemError::DirectoryExists)
+      ReportSuccess(obj);
+    else
+      PrepareError(e, obj);
     PostMessage(response.serialize().c_str());
   };
 
@@ -417,7 +420,10 @@ void FilesystemInstance::FileSystemManagerMakeDirectorySync(
 
   auto onResult = [&](FilesystemError e) {
     LoggerD("enter");
-    PrepareError(e, out);
+    if (e == FilesystemError::DirectoryExists)
+      ReportSuccess(out);
+    else
+      PrepareError(e, out);
   };
 
   FilesystemManager::GetInstance().MakeDirectory(location, onResult);