Skip to content

Commit fb721e1

Browse files
delete states if it exists on run (#3901)
* delete states if it exists * simplify ImmutableComputedVar.__get__ (#3902) * simplify ImmutableComputedVar.__get__ * ruff it --------- Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
1 parent 84ec086 commit fb721e1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

reflex/reflex.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from reflex import constants
1717
from reflex.config import get_config
1818
from reflex.custom_components.custom_components import custom_components_cli
19+
from reflex.state import reset_disk_state_manager
1920
from reflex.utils import console, redir, telemetry
2021

2122
# Disable typer+rich integration for help panels
@@ -180,6 +181,9 @@ def _run(
180181
if prerequisites.needs_reinit(frontend=frontend):
181182
_init(name=config.app_name, loglevel=loglevel)
182183

184+
# Delete the states folder if it exists.
185+
reset_disk_state_manager()
186+
183187
# Find the next available open port if applicable.
184188
if frontend:
185189
frontend_port = processes.handle_port(

reflex/state.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,14 @@ def state_to_schema(
24992499
)
25002500

25012501

2502+
def reset_disk_state_manager():
2503+
"""Reset the disk state manager."""
2504+
states_directory = prerequisites.get_web_dir() / constants.Dirs.STATES
2505+
if states_directory.exists():
2506+
for path in states_directory.iterdir():
2507+
path.unlink()
2508+
2509+
25022510
class StateManagerDisk(StateManager):
25032511
"""A state manager that stores states in memory."""
25042512

0 commit comments

Comments
 (0)