-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Fix windows paths #8449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix windows paths #8449
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -90,18 +90,15 @@ class AppStorageUtils { | |||||||||||||||||
| static Future<Directory> getWindowsAppDataDirectory() async { | ||||||||||||||||||
| if (!Platform.isWindows) throw UnsupportedError("Not running on Windows"); | ||||||||||||||||||
|
|
||||||||||||||||||
| final appData = | ||||||||||||||||||
| Platform.environment['APPDATA'] ?? Platform.environment['LOCALAPPDATA']; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (appData == null || appData.isEmpty) { | ||||||||||||||||||
| final fallback = await getApplicationSupportDirectory(); | ||||||||||||||||||
| final dir = Directory(fallback.path); | ||||||||||||||||||
| if (!await dir.exists()) await dir.create(recursive: true); | ||||||||||||||||||
| return dir; | ||||||||||||||||||
| // On Windows, we want to store app data in C:\Users\Public\Lantern to | ||||||||||||||||||
| // ensure that the Windows service can access it without needing to know | ||||||||||||||||||
| //the specific user profile. The Windows service will create a subdirectory | ||||||||||||||||||
| // called "data" within this directory to store its own data. | ||||||||||||||||||
| final appDataPath = Platform.environment['PUBLIC']; | ||||||||||||||||||
| final appDir = Directory("$appDataPath/Lantern"); | ||||||||||||||||||
|
||||||||||||||||||
| final appDir = Directory("$appDataPath/Lantern"); | |
| if (appDataPath == null || appDataPath.trim().isEmpty) { | |
| throw StateError( | |
| 'The PUBLIC environment variable is not set or is empty; ' | |
| 'cannot determine the shared Windows app-data directory for Lantern.', | |
| ); | |
| } | |
| final appDir = Directory(p.join(appDataPath, 'Lantern')); |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructs a Windows path using string interpolation and a hard-coded "/" separator even though this file already uses package:path elsewhere. Prefer p.join(appDataPath, 'Lantern') (and similar joins) to avoid subtle path formatting issues and keep path handling consistent.
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This async method uses existsSync() (synchronous filesystem I/O) and then awaits create(). For consistency and to avoid blocking the isolate on slow disk/networked profiles, use the async await appDir.exists() pattern like the rest of this file.
| if (!appDir.existsSync()) { | |
| if (!await appDir.exists()) { |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getWindowsAppDataDirectory now points to C:\Users\Public\Lantern, which on typical Windows installations is readable by all local users, and this path is used by getAppDirectory/LocalStorageService to store the ObjectBox DB containing legacyToken, token, oAuthToken, accessToken, and other sensitive user/account data. Any low-privilege local user on the same machine can read the database files under this public directory and hijack accounts or extract PII. Instead, store this data under a per-user app data directory or ensure the shared directory has restricted ACLs so only the service account and the intended user can read it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after the comment marker makes this sentence harder to read; please change
//the specific user profileto// the specific user profile.