async io2db/db2io
This commit is contained in:
parent
6aea9d7044
commit
d99d106f84
@ -193,14 +193,14 @@ class Db:
|
|||||||
self.__path_recover.unlink()
|
self.__path_recover.unlink()
|
||||||
self.__path_backup.unlink()
|
self.__path_backup.unlink()
|
||||||
|
|
||||||
async def _rebuild_file(self, db: {}):
|
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:
|
||||||
self.io2db(file, db)
|
await self.__loop.run_in_executor(None, self.io2db, file, db)
|
||||||
with open(self.__path_backup, "w") as file:
|
with open(self.__path_backup, "w") as file:
|
||||||
self.__initial_size = self.db2io(db, file)
|
self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, db, file)
|
||||||
self.__path_recover.touch()
|
self.__path_recover.touch()
|
||||||
await self._finish_recovery()
|
await self._finish_recovery()
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ class Db:
|
|||||||
await self._dump_buffer()
|
await self._dump_buffer()
|
||||||
self.__file.close()
|
self.__file.close()
|
||||||
with open(self.__path_backup, "w") as file:
|
with open(self.__path_backup, "w") as file:
|
||||||
self.__initial_size = self.db2io(self.__mmdb, file)
|
self.__initial_size = await self.__loop.run_in_executor(None, self.db2io, self.__mmdb, file)
|
||||||
self.__path_recover.touch()
|
self.__path_recover.touch()
|
||||||
await self._finish_recovery()
|
await self._finish_recovery()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user