_build_file
This commit is contained in:
parent
f3429eb1eb
commit
d29d1b1395
@ -209,16 +209,19 @@ class Db:
|
|||||||
self.__path_recover.unlink()
|
self.__path_recover.unlink()
|
||||||
self.__path_backup.unlink()
|
self.__path_backup.unlink()
|
||||||
|
|
||||||
|
async def _build_file(self, db: dict):
|
||||||
|
with open(self.__path_backup, "w") as file:
|
||||||
|
self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, db, file)
|
||||||
|
self.__path_recover.touch()
|
||||||
|
await self._finish_recovery()
|
||||||
|
|
||||||
async def _rebuild_file(self, db: dict):
|
async def _rebuild_file(self, db: dict):
|
||||||
if self.__path_recover.exists():
|
if self.__path_recover.exists():
|
||||||
await self._finish_recovery()
|
await self._finish_recovery()
|
||||||
self.__path.touch()
|
self.__path.touch()
|
||||||
with open(self.__path) as file:
|
with open(self.__path) as file:
|
||||||
await self.__loop.run_in_executor(None, self.io2db, file, db)
|
await self.__loop.run_in_executor(None, self.io2db, file, db)
|
||||||
with open(self.__path_backup, "w") as file:
|
await self._build_file(db)
|
||||||
self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, db, file)
|
|
||||||
self.__path_recover.touch()
|
|
||||||
await self._finish_recovery()
|
|
||||||
|
|
||||||
async def _reload(self):
|
async def _reload(self):
|
||||||
self.__file.close()
|
self.__file.close()
|
||||||
@ -257,10 +260,7 @@ class Db:
|
|||||||
self.__task.cancel()
|
self.__task.cancel()
|
||||||
await self._dump_buffer()
|
await self._dump_buffer()
|
||||||
self.__file.close()
|
self.__file.close()
|
||||||
with open(self.__path_backup, "w") as file:
|
await self._build_file(self.__mmdb)
|
||||||
self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, self.__mmdb, file)
|
|
||||||
self.__path_recover.touch()
|
|
||||||
await self._finish_recovery()
|
|
||||||
|
|
||||||
def _uninitialize(self):
|
def _uninitialize(self):
|
||||||
self.__mmdb = None
|
self.__mmdb = None
|
||||||
|
Loading…
Reference in New Issue
Block a user