diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 448d306..a0abe86 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -31,7 +31,7 @@ "fs:allow-applocaldata-write", { "identifier": "fs:scope", - "allow": [{ "path": "$APPLOCALDATA/game/**" }] + "allow": [{ "path": "$APPLOCALDATA/game/**" }, { "path": "$APPCONFIG/versions.json" }] }, { "identifier": "opener:allow-open-path", diff --git a/src/app/main/layout.tsx b/src/app/main/layout.tsx index f8dbf6c..345b96c 100644 --- a/src/app/main/layout.tsx +++ b/src/app/main/layout.tsx @@ -17,6 +17,7 @@ import { } from '@tauri-apps/plugin-notification' import { BaseDirectory, + copyFile, exists, readTextFile, remove @@ -280,6 +281,29 @@ export default function RootLayout ({ setLoadingText('Failed to download versions list.') return } + const legacyOptions = { + baseDir: BaseDirectory.AppLocalData + } + if ( + platform() == 'windows' && + (await exists('versions.json', legacyOptions)) + ) { + if ( + await exists('versions.json', { + baseDir: BaseDirectory.AppConfig + }) + ) + await remove('versions.json', { + baseDir: BaseDirectory.AppConfig + }) + + await copyFile('versions.json', 'versions.json', { + fromPathBaseDir: BaseDirectory.AppLocalData, + toPathBaseDir: BaseDirectory.AppConfig + }) + await remove('versions.json', legacyOptions) + } + const settingsLocal = await load('settings.json', { autoSave: true, defaults: { @@ -301,9 +325,6 @@ export default function RootLayout ({ }) settingsLocal.set('version', client) versionsLocal.set('version', client) - const legacyOptions = { - baseDir: BaseDirectory.AppLocalData - } if (await exists('config.json', legacyOptions)) { const config = await readTextFile('config.json', legacyOptions) const raw = JSON.parse(config)