Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
viavr-editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIA-VR
viavr-editor
Commits
80e979c9
Commit
80e979c9
authored
4 weeks ago
by
Samuel Truman
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: prevent writing an empty preferences file on crash
parent
b7d33dd4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/Utils/SettingsManager.ts
+5
-4
5 additions, 4 deletions
backend/Utils/SettingsManager.ts
with
5 additions
and
4 deletions
backend/Utils/SettingsManager.ts
+
5
−
4
View file @
80e979c9
...
...
@@ -35,7 +35,7 @@ export default class SettingsManager {
if
(
!
this
.
initialized
)
await
this
.
init
()
if
(
!
this
.
initialized
)
throw
new
Error
(
'
SettingsManager not initialized
'
)
this
.
settings
[
name
]
=
value
await
this
.
saveSettingToFile
()
this
.
saveSettingToFile
()
this
.
settingUpdateEvents
[
name
]?.
emit
(
'
update
'
,
value
)
}
...
...
@@ -57,7 +57,7 @@ export default class SettingsManager {
}
}
await
this
.
saveSettingToFile
()
this
.
saveSettingToFile
()
this
.
settingUpdateEvents
[
'
anySetting
'
]?.
emit
(
'
update
'
,
undefined
)
// emit update event for any setting. Systems have to load the new value themselves.
}
...
...
@@ -75,7 +75,8 @@ export default class SettingsManager {
this
.
settings
=
JSON
.
parse
(
data
.
toString
())
}
public
async
saveSettingToFile
(
path
:
string
=
this
.
settingsPath
)
{
await
fs
.
writeFile
(
path
,
JSON
.
stringify
(
this
.
settings
,
null
,
2
))
public
saveSettingToFile
(
path
:
string
=
this
.
settingsPath
)
{
if
(
!
this
.
settings
||
Object
.
keys
(
this
.
settings
).
length
===
0
)
return
fs2
.
writeFileSync
(
path
,
JSON
.
stringify
(
this
.
settings
,
null
,
2
))
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment