fix: use local app data directory on desktop platforms#179
Open
ProjectEdge-Jim wants to merge 2 commits intoDenisovAV:mainfrom
Open
fix: use local app data directory on desktop platforms#179ProjectEdge-Jim wants to merge 2 commits intoDenisovAV:mainfrom
ProjectEdge-Jim wants to merge 2 commits intoDenisovAV:mainfrom
Conversation
7369689 to
ca94839
Compare
On desktop platforms, the Documents folder is often synced to cloud services (OneDrive, iCloud, Dropbox). Large model files (~3.6GB) in these folders cause issues with native code file access - specifically, LiteRT-LM's JNI layer cannot reliably access files in cloud-synced locations. This change uses platform-specific local app data directories that are never synced: - Windows: %LOCALAPPDATA%\flutter_gemma (truly local, never synced) - macOS: ~/Library/Application Support/flutter_gemma - Linux: ~/.local/share/flutter_gemma (respects XDG_DATA_HOME) Mobile platforms (Android/iOS) continue to use the Documents directory as before. Fixes issues with OneDrive/iCloud/Dropbox sync interfering with model loading on desktop platforms.
ca94839 to
70eed33
Compare
Task.split() has a bug where it strips the drive letter from Windows paths that don't match known base directories. This fix manually handles Windows paths to preserve the full directory path including drive letter. Fixes model downloads to custom directories like %LOCALAPPDATA%\OroForge\models
Owner
|
Thanks for the PR! This is a real issue — OneDrive virtualized paths don't work well with native JNI code. A few things I noticed:
Directory(path.join(localAppData, 'OroForge', 'models'))Not sure if this is intentional? Should probably be
Could you clarify the OroForge naming and consolidate the directory logic? Happy to merge after that. |
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.
Summary
On desktop platforms, the Documents folder is often synced to cloud services (OneDrive, iCloud, Dropbox). Large model files (~3.6GB) in these folders cause issues with native code file access - specifically, LiteRT-LM's JNI layer cannot reliably access files in cloud-synced locations.
This change uses platform-specific local app data directories that are never synced:
%LOCALAPPDATA%\flutter_gemma~/Library/Application Support/flutter_gemma~/.local/share/flutter_gemmaXDG_DATA_HOMEProblem
When a Windows user has OneDrive enabled (which syncs the Documents folder), downloading a Gemma model via
getApplicationDocumentsDirectory()places the ~3.6GB file in a cloud-synced location. The LiteRT-LM native JNI code then fails to load the model with:The file exists but native code cannot access it through the OneDrive virtualized path.
Solution
Use
%LOCALAPPDATA%on Windows instead ofgetApplicationDocumentsDirectory(). This directory:Similar platform-appropriate directories are used on macOS and Linux.
Testing
C:\Users\<user>\AppData\Local\flutter_gemma\Breaking Changes
None. Mobile platforms (Android/iOS) continue to use the Documents directory as before. Existing desktop users will need to re-download the model to the new location.