diff --git a/server/Files.py b/server/Files.py index ffa1bbb..b9b64be 100644 --- a/server/Files.py +++ b/server/Files.py @@ -1,6 +1,7 @@ import aiofiles.os import aiofiles import os +import inspect async def read_file(path: str, callback=None): if not await aiofiles.os.path.exists(path): @@ -8,7 +9,10 @@ async def read_file(path: str, callback=None): async with aiofiles.open(path, "r") as f: if callback: - return await callback(f) + result = callback(f) + if inspect.isawaitable(result): + return await result + return result return await f.read() @@ -19,6 +23,8 @@ async def save_file(path: str, data, callback=None, *args, **kwargs): async with aiofiles.open(path, "w") as f: if callback: - await callback(data, f, *args, **kwargs) + result = callback(data, f, *args, **kwargs) + if inspect.isawaitable(result): + await result else: await f.write(data)