Эх сурвалжийг харах

Улучшение обработки ошибок

Book Pauk 2 жил өмнө
parent
commit
6bdfdebeaf

+ 7 - 1
server/core/WebWorker.js

@@ -146,7 +146,13 @@ class WebWorker {
                 await fs.remove(dbPath);
 
             if (!await fs.pathExists(dbPath)) {
-                await this.createDb(dbPath);
+                try {
+                    await this.createDb(dbPath);
+                } catch (e) {
+                    //при ошибке создания БД удалим ее, чтобы не работать с поломанной базой при следующем запуске
+                    await fs.remove(dbPath);
+                    throw e;
+                }
                 utils.freeMemory();
             }