]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/immutable_object_cache/ObjectCacheStore.cc
import 15.2.5
[ceph.git] / ceph / src / tools / immutable_object_cache / ObjectCacheStore.cc
index b3b793d7c2daefc895b2efc25cc9e8adc1d4d363..ece4127df850b7159290389f2ea30e937438599e 100644 (file)
@@ -60,17 +60,19 @@ int ObjectCacheStore::init(bool reset) {
 
   // TODO(dehao): fsck and reuse existing cache objects
   if (reset) {
-    std::error_code ec;
-    if (efs::exists(m_cache_root_dir)) {
-      // remove all sub folders
-      for (auto& p : efs::directory_iterator(m_cache_root_dir)) {
-        efs::remove_all(p.path());
-      }
-    } else {
-      if (!efs::create_directories(m_cache_root_dir, ec)) {
-        lderr(m_cct) << "fail to create cache store dir: " << ec << dendl;
-        return ec.value();
+    try {
+      if (efs::exists(m_cache_root_dir)) {
+        // remove all sub folders
+        for (auto& p : efs::directory_iterator(m_cache_root_dir)) {
+          efs::remove_all(p.path());
+        }
+      } else {
+        efs::create_directories(m_cache_root_dir);
       }
+    } catch (const efs::filesystem_error& e) {
+      lderr(m_cct) << "failed to initialize cache store directory: "
+                   << e.what() << dendl;
+      return -e.code().value();
     }
   }
   return 0;