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>
This commit is contained in:
parent
84ec08616b
commit
fb721e1d12
@ -16,6 +16,7 @@ from reflex_cli.utils import dependency
|
||||
from reflex import constants
|
||||
from reflex.config import get_config
|
||||
from reflex.custom_components.custom_components import custom_components_cli
|
||||
from reflex.state import reset_disk_state_manager
|
||||
from reflex.utils import console, redir, telemetry
|
||||
|
||||
# Disable typer+rich integration for help panels
|
||||
@ -180,6 +181,9 @@ def _run(
|
||||
if prerequisites.needs_reinit(frontend=frontend):
|
||||
_init(name=config.app_name, loglevel=loglevel)
|
||||
|
||||
# Delete the states folder if it exists.
|
||||
reset_disk_state_manager()
|
||||
|
||||
# Find the next available open port if applicable.
|
||||
if frontend:
|
||||
frontend_port = processes.handle_port(
|
||||
|
@ -2499,6 +2499,14 @@ def state_to_schema(
|
||||
)
|
||||
|
||||
|
||||
def reset_disk_state_manager():
|
||||
"""Reset the disk state manager."""
|
||||
states_directory = prerequisites.get_web_dir() / constants.Dirs.STATES
|
||||
if states_directory.exists():
|
||||
for path in states_directory.iterdir():
|
||||
path.unlink()
|
||||
|
||||
|
||||
class StateManagerDisk(StateManager):
|
||||
"""A state manager that stores states in memory."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user