io2db2io _copy_sync

This commit is contained in:
AF 2022-11-04 06:53:12 +00:00
parent 243741346e
commit 89cbb24386

View File

@ -3,7 +3,6 @@ import concurrent.futures
import json
import pathlib
import pickle
import shutil
import traceback
from io import StringIO
from typing import Any, Optional, IO, Type, Hashable
@ -226,7 +225,11 @@ class DbConnection:
await self._background_cycle()
def _copy_sync(self):
shutil.copyfile(self.__path_backup, self.__path)
db = {}
with open(self.__path_backup) as file:
self.io2db(file, db)
with open(self.__path, 'w') as file:
self.db2io(db, file)
async def _copy(self):
with concurrent.futures.ThreadPoolExecutor() as pool: