-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: config reset on app restart and improve migrations handling #394
Conversation
Test this pull request on windows-latestDownload the correct version for your architecture: |
Test this pull request on macos-latestDownload the correct version for your architecture:Click here if you don't know which version to downloadFor running this unsigned version of the app, you will need to run the xattr command on it:
|
|
||
// Initialize with default values if empty | ||
const existingConfig = await storage.get<Record<string, any>>(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was the bug, this always returns undefined
, and causes the default config to be applied over the existing one.
const [projectPath] = await invoke('electron.showOpenDialog', { | ||
title: 'Import project', | ||
properties: ['openDirectory'], | ||
defaultPath: config.settings.scenesPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a quality-of-life improvement for users
for (const [key, value] of Object.entries(mergedConfig)) { | ||
await storage.set(key, value); | ||
export async function getConfig(): Promise<IFileSystemStorage> { | ||
await waitForMigrations(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just to avoid possible race conditions between the migration of the config and the initialization of the default values.
266c68e
to
7b01fac
Compare
7b01fac
to
cb87e5d
Compare
I just finished testing on Windows and Mac 🤦🏽. Anyways, here's the evidence and the tests performed:
Scene Preview:ch.persist.mp4Scenes persist after restarting:CH.V0.17.0.FIX.mp4Publish a scene:scene.published.mp4 |
Fix config reset on app restart and improve migrations handling
Config Reset Bug
The config was being reset to default values on app restart because we were incorrectly using
storage.get('')
to check for config existence. This was unreliable and caused the config to reset even when valid data existed.Fix
getAll()
andsetAll()
methods to read/write entire config state at onceMigrations Improvement
Added synchronization to prevent race conditions between config operations and migrations:
waitForMigrations()
utility usingfp-future
getConfig()
to await migrations before proceedingV2 Migration
Added version-based migration that automatically includes scene directories in workspace:
scenesPath
for valid scenes (containing scene.json)Testing