Skip to content

Commit

Permalink
Release v0.9.3
Browse files Browse the repository at this point in the history
* maintain a copy of all control reference JSON files at %APPDATA%\DCS-BIOS\control-reference-json for DCSFlightpanels users
  • Loading branch information
jboecker committed Nov 7, 2019
2 parents 73ebd4f + 81336ea commit eee7a5c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v0.9.2+{build}
version: v0.9.3+{build}
pull_requests:
do_not_increment_build_number: true
branches:
Expand Down
1 change: 1 addition & 0 deletions src/hub-backend/configstore/configstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func MakeDirs() error {
dir := os.ExpandEnv("${APPDATA}")
os.MkdirAll(filepath.Join(dir, "DCS-BIOS", "Config"), 0600)
os.MkdirAll(filepath.Join(dir, "DCS-BIOS", "Plugins"), 0600)
os.MkdirAll(filepath.Join(dir, "DCS-BIOS", "control-reference-json"), 0600)
return nil
}

Expand Down
15 changes: 15 additions & 0 deletions src/hub-backend/controlreference/controlreference.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package controlreference
import (
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -168,6 +169,12 @@ func (crs *ControlReferenceStore) UnloadModuleDefinition(moduleName string) {
_, ok := crs.modules[moduleName]
if ok {
delete(crs.modules, moduleName)

jsonCopyFilePath := filepath.Join(os.ExpandEnv("${APPDATA}"), "DCS-BIOS", "control-reference-json", moduleName+".json")
stat, err := os.Stat(jsonCopyFilePath)
if err == nil && !stat.IsDir() {
os.Remove(jsonCopyFilePath)
}
}
}

Expand All @@ -193,6 +200,14 @@ func (crs *ControlReferenceStore) LoadFile(filename string) error {

crs.modules[moduleName] = module

jsonCopyFilePath := filepath.Join(os.ExpandEnv("${APPDATA}"), "DCS-BIOS", "control-reference-json", moduleName+".json")
f.Seek(0, 0)
copy, err := os.Create(jsonCopyFilePath)
if err == nil {
io.Copy(copy, f)
}
copy.Close()

for moduleName, module := range crs.modules {
for categoryName, cat := range module {
for elementName, elem := range cat {
Expand Down

0 comments on commit eee7a5c

Please sign in to comment.