fix: 将异步写入函数改为同步,以确保文件写入的稳定性
This commit is contained in:
parent
246e133eb4
commit
54bb8e1e4f
@ -285,7 +285,7 @@ class Tasker:
|
|||||||
tasks = [task.to_dict() for task in self._tasks.values()]
|
tasks = [task.to_dict() for task in self._tasks.values()]
|
||||||
payload = {"tasks": tasks, "updated_at": _utc_timestamp()}
|
payload = {"tasks": tasks, "updated_at": _utc_timestamp()}
|
||||||
|
|
||||||
async def _write() -> None:
|
def _write() -> None:
|
||||||
self._storage_path.parent.mkdir(parents=True, exist_ok=True)
|
self._storage_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
tmp_path = self._storage_path.with_suffix(".tmp")
|
tmp_path = self._storage_path.with_suffix(".tmp")
|
||||||
with open(tmp_path, "w", encoding="utf-8") as fh:
|
with open(tmp_path, "w", encoding="utf-8") as fh:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user