fix: resolve Windows path mismatch between setup write and runtime read#1712
Open
octo-patch wants to merge 1 commit intoWei-Shaw:mainfrom
Open
fix: resolve Windows path mismatch between setup write and runtime read#1712octo-patch wants to merge 1 commit intoWei-Shaw:mainfrom
octo-patch wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
…ad (fixes Wei-Shaw#1701) On Windows, the path /app/data resolves to the drive root (e.g., C:\app\data), causing setup.GetDataDir() and config load() to potentially resolve to different directories when the CWD changes between the initial setup and subsequent restarts. Changes: - Restrict /app/data check to Linux only in both GetDataDir() and load(), preventing the Windows path drift - Use the executable's directory as the primary fallback instead of CWD, so both setup and runtime always agree on the data directory location - Mirror the same path resolution logic in config.load() via a new getDataDir() helper, eliminating the divergence between the two codepaths - Change the default timezone from Asia/Shanghai to UTC for cross-platform compatibility (Asia/Shanghai can fail on some Windows PostgreSQL setups) - Return an OS-accurate restart message from the install API: Windows users are now told to restart manually instead of expecting automatic restart - Improve the non-Linux log message in RestartService() for clarity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1701
Problem
On Windows, the path
/app/dataresolves to the current drive root (e.g.,C:\app\data), not a Docker-style path. This causes a divergence between:GetDataDir()): falls back to current directory.when/app/datadoesn't existconfig.load()): always searches/app/datafirst in viper, then.If the working directory changes between the initial setup and a subsequent restart (common when launching via double-click or as a Windows service), the runtime can end up looking in a completely different directory for
config.yaml, causing the Setup Wizard to reappear.Solution
Restrict
/app/datato Linux only in bothGetDataDir()and the newgetDataDir()helper inconfig.go. This eliminates the ambiguous path on Windows.Use the executable's directory as the primary fallback (before CWD). The exe directory is stable regardless of how the process is launched — direct double-click, service, or shell — making both setup and runtime always agree on the data location.
Mirror path resolution in
config.load()via a privategetDataDir()helper that matchessetup.GetDataDir()logic exactly, closing the divergence without introducing a circular import.Default timezone changed from
Asia/ShanghaitoUTCinsetup.writeConfigFile()andtimezone.Init().Asia/Shanghaican cause startup failures on some Windows PostgreSQL configurations; UTC is universally accepted.OS-accurate restart message from the install API: Windows users are now told "Please restart the application manually." instead of the misleading "Service will restart automatically." The
restartfield in the JSON response also accurately reflects whether auto-restart is supported.Testing
/app/datais still checked first when it exists and is writable — no behavior change for the primary deployment target.filepath.Dir(os.Executable()), so they always agree, regardless of CWD.TestWriteConfigFileKeepsDefaultUserConcurrencycontinues to pass (it setsDATA_DIRwhich is handled before any platform-specific logic).