diff --git a/poetry.lock b/poetry.lock index 66359cb..68baa38 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,16 +1,5 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. -[[package]] -name = "aiofiles" -version = "24.1.0" -description = "File support for asyncio." -optional = false -python-versions = ">=3.8" -files = [ - {file = "aiofiles-24.1.0-py3-none-any.whl", hash = "sha256:b4ec55f4195e3eb5d7abd1bf7e061763e864dd4954231fb8539a0ef8bb8260e5"}, - {file = "aiofiles-24.1.0.tar.gz", hash = "sha256:22a075c9e5a3810f0c2e48f3008c94d68c65d763b9b03857924c99e57355166c"}, -] - [[package]] name = "aiohappyeyeballs" version = "2.3.5" @@ -1042,4 +1031,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "27b0f4ead7c887aebd3b02cc312f47b4b3bb2c1c80f0f2d6cf5ce60494952fe8" +content-hash = "bc98a45353566e77b38104fd1dfd6ece7fa5f48823e9ca44181e96ea870d09de" diff --git a/pyproject.toml b/pyproject.toml index 97b0821..7329660 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ discord-py = "^2.4.0" twitchapi = "^4.3.1" pydantic = "^2.9.2" pydantic-settings = "^2.6.1" -aiofiles = "^24.1.0" httpx = "^0.27.2" icalendar = "^6.0.1" pytz = "^2024.2" diff --git a/src/services/twitch/token_storage.py b/src/services/twitch/token_storage.py index fa76182..13cd018 100644 --- a/src/services/twitch/token_storage.py +++ b/src/services/twitch/token_storage.py @@ -1,9 +1,3 @@ -from asyncio import Lock -import json - -import aiofiles - -from core.config import config from core.mongo import mongo_manager @@ -11,16 +5,10 @@ class TokenStorage: COLLECTION_NAME = "secrets" OBJECT_ID = "twitch_tokens" - lock = Lock() - @staticmethod async def save(acceess_token: str, refresh_token: str): data = {"access_token": acceess_token, "refresh_token": refresh_token} - async with TokenStorage.lock: - async with aiofiles.open(config.SECRETS_FILE_PATH, "w") as f: - await f.write(json.dumps(data)) - async with mongo_manager.connect() as client: db = client.get_default_database() collection = db[TokenStorage.COLLECTION_NAME] @@ -38,15 +26,5 @@ class TokenStorage: collection = db[TokenStorage.COLLECTION_NAME] data = await collection.find_one({"_id": TokenStorage.OBJECT_ID}) - if data is not None: - return data["access_token"], data["refresh_token"] - async with TokenStorage.lock: - async with aiofiles.open(config.SECRETS_FILE_PATH, "r") as f: - data_str = await f.read() - - data = json.loads(data_str) - - await TokenStorage.save(data["access_token"], data["refresh_token"]) - - return data["access_token"], data["refresh_token"] + return data["access_token"], data["refresh_token"]