Never remove database files on shutdown, it caused unreadable wallets on some testers...
[novacoin.git] / src / db.cpp
index b48be7a..5cacf19 100644 (file)
@@ -28,7 +28,7 @@ DbEnv dbenv(0);
 static map<string, int> mapFileUseCount;
 static map<string, Db*> mapDb;
 
-static void EnvShutdown(bool fRemoveLogFiles)
+static void EnvShutdown()
 {
     if (!fDbEnvInit)
         return;
@@ -43,24 +43,6 @@ static void EnvShutdown(bool fRemoveLogFiles)
         printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno());
     }
     DbEnv(0).remove(GetDataDir().c_str(), 0);
-
-    if (fRemoveLogFiles)
-    {
-        filesystem::path datadir(GetDataDir());
-        filesystem::directory_iterator it(datadir / "database");
-        while (it != filesystem::directory_iterator())
-        {
-            const filesystem::path& p = it->path();
-#if BOOST_FILESYSTEM_VERSION >= 3
-            std::string f = p.filename().generic_string();
-#else
-            std::string f = p.filename();
-#endif
-            if (f.find("log.") == 0)
-                filesystem::remove(p);
-            ++it;
-        }
-    }
 }
 
 class CDBInit
@@ -71,7 +53,7 @@ public:
     }
     ~CDBInit()
     {
-        EnvShutdown(false);
+        EnvShutdown();
     }
 }
 instance_of_cdbinit;
@@ -289,7 +271,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
 }
 
 
-void DBFlush(bool fShutdown, bool fRemoveLogFiles)
+void DBFlush(bool fShutdown)
 {
     // Flush log data to the actual data file
     //  on all files that are not in use
@@ -322,7 +304,7 @@ void DBFlush(bool fShutdown, bool fRemoveLogFiles)
             if (mapFileUseCount.empty())
             {
                 dbenv.log_archive(&listp, DB_ARCH_REMOVE);
-                EnvShutdown(fRemoveLogFiles);
+                EnvShutdown();
             }
         }
     }