Skip to content

[Bug]: bugs in load_state from state management #56

@Keshav-writes-code

Description

@Keshav-writes-code

Branch : feat/state_management

Problem

the porblem is that current implmentaiton of the load_states function from the persistency module in rust does the following

Situation 1

the app schema is newer than the stored schema.
when app first lauches:

  • frontend calls the tauri command get_persistent_states() on mount (using onMount from svelte)
  • get_persistent_states() calls the load_state() funtion
  • load_state() reads the file config.json
  • app schema is newer than config.json schema (just the structure)
  • returns an Err immediately without even reaching the migration. expected behaviour was for it to run migrate old schema to app;s schema because that's when migration should run

Situation 2

the app schema is older than stored schema.
when the first lauches:

  • frontend calls the tauri command get_persistent_states() on mount (using onMount from svelte)
  • get_persistent_states() calls the load_state() funtion
  • load_state() reads the file config.json
  • app schema is older than config.json schema (just the structure)
  • returns an Err immediately. expected behaviour was for it to use default config values

Situation 3

the app schema is same as the stored schema.

this initially works but breaks when the schema_version field in config.json is incorrectly set higher than the app schema. if that happens then on app lauch :

  • frontend calls the tauri command get_persistent_states() on mount (using onMount from svelte)
  • get_persistent_states() calls the load_state() funtion
  • load_state() reads the file config.json
  • app schema is same as the config.json schema (just the structure)
  • check if the schema_version is equal to the app schema version (which is just a number)
  • runs migrations when it shouldn't have becuase the schema structure was already set to the app schema but with incorrectly higher schema_version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions