You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The persistent storage is implemented with electron-store. This module just writes the data into a config.json (put somewhere on the users machine). When this data is read, it is currently just typed as StorageState. But if the data of the JSON file does not match the expected shape, the file explorer can crash.
This already happened during development if the shape was changed but config.json contained data with the old shape.
Desired Behavior
When data is read from the persistent storage, validate that data according to a schema resembling StorageState before continuing. Either using https://github.com/colinhacks/zod or https://github.com/sinclairzx81/typebox + https://github.com/ajv-validator/ajv.
If a validation error occurs, continue with a "blank" state (as if the file explorer started for the first time). This means that any stored data on the user's machine is lost. At the moment, only the explorer tabs are persisted, so no meaningful data should be lost. However, in the future there might be some meaningful data stored in the persistent storage (e.g. tags for files&folders).
In general, changes of the shape of StorageState (and thus, effectively, config.json) should be done in a backwards-compatible manner.
pkerschbaum
changed the title
[Improvement]: Perform schema validation when reading from persistent storage
[Tech]: Perform schema validation when reading from persistent storage
Jan 13, 2022
Current Behavior
The persistent storage is implemented with
electron-store
. This module just writes the data into aconfig.json
(put somewhere on the users machine). When this data is read, it is currently just typed asStorageState
. But if the data of the JSON file does not match the expected shape, the file explorer can crash.This already happened during development if the shape was changed but
config.json
contained data with the old shape.Desired Behavior
When data is read from the persistent storage, validate that data according to a schema resembling
StorageState
before continuing. Either using https://github.com/colinhacks/zod or https://github.com/sinclairzx81/typebox + https://github.com/ajv-validator/ajv.If a validation error occurs, continue with a "blank" state (as if the file explorer started for the first time). This means that any stored data on the user's machine is lost. At the moment, only the explorer tabs are persisted, so no meaningful data should be lost. However, in the future there might be some meaningful data stored in the persistent storage (e.g. tags for files&folders).
In general, changes of the shape of
StorageState
(and thus, effectively,config.json
) should be done in a backwards-compatible manner.Implementation Notes
The text was updated successfully, but these errors were encountered: