hash the state file name (#4000)

* hash the state file name

* forgot to digest my food oop
This commit is contained in:
Khaleel Al-Adhami 2024-09-25 13:11:04 -07:00 committed by GitHub
parent e1538b75f8
commit 9d8b737b1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ import os
import uuid import uuid
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from collections import defaultdict from collections import defaultdict
from hashlib import md5
from pathlib import Path from pathlib import Path
from types import FunctionType, MethodType from types import FunctionType, MethodType
from typing import ( from typing import (
@ -2704,7 +2705,9 @@ class StateManagerDisk(StateManager):
Returns: Returns:
The path for the token. The path for the token.
""" """
return (self.states_directory / f"{token}.pkl").absolute() return (
self.states_directory / f"{md5(token.encode()).hexdigest()}.pkl"
).absolute()
async def load_state(self, token: str, root_state: BaseState) -> BaseState: async def load_state(self, token: str, root_state: BaseState) -> BaseState:
"""Load a state object based on the provided token. """Load a state object based on the provided token.