Merge branch 'main' into patching

This commit is contained in:
SpikeHD
2022-07-16 16:38:54 -07:00
4 changed files with 60 additions and 17 deletions

View File

@@ -1,10 +1,12 @@
import { fs } from '@tauri-apps/api'
import { fs, invoke } from '@tauri-apps/api'
export async function toggleEncryption(path: string) {
let serverConf
try {
serverConf = JSON.parse(await fs.readTextFile(path))
serverConf = JSON.parse(await invoke('read_file', {
path,
}))
} catch(e) {
console.log(`Server config at ${path} not found or invalid`)
return
@@ -16,7 +18,7 @@ export async function toggleEncryption(path: string) {
serverConf.server.http.encryption.useInRouting = !enabled
// Write file
await fs.writeFile({
await invoke('write_file', {
path,
contents: JSON.stringify(serverConf, null, 2),
})
@@ -26,7 +28,9 @@ export async function encryptionEnabled(path: string) {
let serverConf
try {
serverConf = JSON.parse(await fs.readTextFile(path))
serverConf = JSON.parse(await invoke('read_file', {
path,
}))
} catch(e) {
console.log(`Server config at ${path} not found or invalid`)
return false