Browse Source

hash the state file name (#4000)

* hash the state file name

* forgot to digest my food oop
Khaleel Al-Adhami 7 months ago
parent
commit
9d8b737b1a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      reflex/state.py

+ 4 - 1
reflex/state.py

@@ -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.