Skip to content

Comments

Fix windows paths#8449

Merged
myleshorton merged 4 commits intomainfrom
myles/windows-paths
Feb 6, 2026
Merged

Fix windows paths#8449
myleshorton merged 4 commits intomainfrom
myles/windows-paths

Conversation

@myleshorton
Copy link
Contributor

This pull request introduces improvements for developers and updates how application data is stored on Windows. The most significant change is to the Windows app data storage location, ensuring compatibility with the Windows service. Additionally, developer documentation has been clarified and expanded to help new contributors.

Developer Documentation Improvements:

  • Added a "Developers" section to README.md with a link to the new developer README for build instructions and contribution guidelines.
  • Renamed README-outline.md to README-dev.md and updated the Windows build instructions to clarify the shared library build step and re-ordered steps for clarity.

Windows App Data Storage Update:

  • Changed the getWindowsAppDataDirectory method in storage_utils.dart to store app data in C:\Users\Public\Lantern instead of user-specific directories, ensuring the Windows service can access shared data without needing user profile information.

@myleshorton myleshorton merged commit 41dc39c into main Feb 6, 2026
8 checks passed
@myleshorton myleshorton deleted the myles/windows-paths branch February 6, 2026 17:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Windows storage path handling to use a shared, service-accessible location and improves developer documentation by adding/clarifying build instructions and linking them from the main README.

Changes:

  • Updated Windows app data base directory logic to use the Public profile location for service compatibility.
  • Added a “Developers” section to README.md linking to the developer-focused README.
  • Clarified Windows dev build steps in README-dev.md by adding the shared library build step.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.

File Description
lib/core/utils/storage_utils.dart Changes Windows app data base path to a shared directory to align with Windows service access patterns.
README.md Adds a developer entry point linking to the developer documentation.
README-dev.md Expands/reorders Windows build instructions to include the shared library build step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

//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");
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform.environment['PUBLIC'] can be null/empty in some Windows execution contexts. If that happens, this will create/return a relative directory like null/Lantern (or /Lantern), which is not the intended shared app-data location. Add validation and a deterministic fallback (or throw a clear error) before constructing the directory path.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +98 to +99
final appDir = Directory("$appDataPath/Lantern");
if (!appDir.existsSync()) {
Copy link

Copilot AI Feb 6, 2026

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 uses AI. Check for mistakes.
// called "data" within this directory to store its own data.
final appDataPath = Platform.environment['PUBLIC'];
final appDir = Directory("$appDataPath/Lantern");
if (!appDir.existsSync()) {
Copy link

Copilot AI Feb 6, 2026

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.

Suggested change
if (!appDir.existsSync()) {
if (!await appDir.exists()) {

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Feb 6, 2026

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 profile to // the specific user profile.

Suggested change
//the specific user profile. The Windows service will create a subdirectory
// the specific user profile. The Windows service will create a subdirectory

Copilot uses AI. Check for mistakes.
Comment on lines +97 to 102
final appDataPath = Platform.environment['PUBLIC'];
final appDir = Directory("$appDataPath/Lantern");
if (!appDir.existsSync()) {
await appDir.create(recursive: true);
}

final appDir = Directory(p.join(appData, "Lantern"));
if (!await appDir.exists()) await appDir.create(recursive: true);
return appDir;
Copy link

Copilot AI Feb 6, 2026

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.

Copilot uses AI. Check for mistakes.
atavism pushed a commit that referenced this pull request Feb 9, 2026
* Added windows build step

* Added link to dev README

* Fixed windows paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant