Skip to content

Create FwLite data directories at FwLiteWeb startup#2417

Open
imnasnainaec wants to merge 1 commit into
developfrom
fwlite/ensure-web-data-dirs
Open

Create FwLite data directories at FwLiteWeb startup#2417
imnasnainaec wants to merge 1 commit into
developfrom
fwlite/ensure-web-data-dirs

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

FwLiteWeb never created its project or auth-cache directories, unlike the MAUI host (FwLiteMauiKernel). That was harmless while the paths defaulted to the working directory (always present), but a host can point LcmCrdt:ProjectPath / Auth:CacheFileName at a per-user location that doesn't exist yet — and can't create it itself. When the directory is missing, three things throw on a fresh install:

  • Project listingCrdtProjectsService.ListProjects() calls Directory.EnumerateFiles(ProjectPath, "*.sqlite") with no existence guard → DirectoryNotFoundException.
  • Project creation — opens a SQLite connection under ProjectPath; Microsoft.Data.Sqlite won't create parent dirs → "unable to open database file".
  • Sign-inMsalCacheHelper.CreateAsync opens a lockfile in the cache dir.

This creates both directories up front in SetupAppServer, mirroring what the MAUI host already does. Doing it in the backend covers every host, not just the one passing the path.

Addresses point 1 (the blocking finding) of the review on #2385: #2385 (comment) — the finding this PR unblocks stems from #2385 pointing FW Lite's data at ~/.platform.bible/extensions/lexicon/ (closes #2351).

Test plan

  • dotnet build FwLiteWeb/FwLiteWeb.csproj succeeds (no new warnings)
  • With --LcmCrdt:ProjectPath / --Auth:CacheFileName pointed at a non-existent per-user dir, FwLiteWeb starts, lists/creates projects, and signs in without a DirectoryNotFoundException

🤖 Generated with Claude Code

Devin review: https://app.devin.ai/review/sillsdev/languageforge-lexbox/pull/2417

FwLiteWeb never created its project or auth-cache directories, unlike the
MAUI host (FwLiteMauiKernel). That was harmless while the paths defaulted
to the working directory, but a host can point LcmCrdt:ProjectPath and
Auth:CacheFileName at a per-user location that doesn't exist yet. When it
does, a missing directory makes project listing (Directory.EnumerateFiles),
project creation (SQLite open), and MSAL cache init all throw.

Create both directories up front in SetupAppServer so every host — not just
the one passing the path — is covered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 12d6dd90-44e9-485e-b6a1-a09f5ed9e315

📥 Commits

Reviewing files that changed from the base of the PR and between 915ca19 and 407c5b4.

📒 Files selected for processing (1)
  • backend/FwLite/FwLiteWeb/FwLiteWebServer.cs

📝 Walkthrough

Walkthrough

FwLiteWebServer.cs now creates required data directories (LCM project path and MSAL auth cache file directory) at startup, before the HTTP request pipeline is configured, via a new private helper called from SetupAppServer.

Changes

Startup directory creation

Layer / File(s) Summary
Ensure data directories exist at startup
backend/FwLite/FwLiteWeb/FwLiteWebServer.cs
Adds EnsureDataDirectoriesExist(WebApplication app) which creates LcmCrdtConfig.ProjectPath and the directory of AuthConfig.CacheFileName, called from SetupAppServer right after builder.Build().

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit hops with folders in tow,
Creating paths where data will flow,
No more missing dirs to make us fret,
Startup's smooth as a burrow, you bet!
🐇📁✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning [#2351] The change creates missing directories, but it does not move mutable state off the binary-relative install dir. Pass stable per-user data paths at launch or add a base data-dir setting, and migrate project, auth-cache, and log locations off the versioned install dir.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: creating FwLite data directories at startup.
Description check ✅ Passed The description clearly matches the change and explains the startup directory creation rationale and test plan.
Out of Scope Changes check ✅ Passed The PR only adds startup directory creation in the touched server file and introduces no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fwlite/ensure-web-data-dirs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jul 6, 2026
@argos-ci

argos-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 6, 2026, 2:34 PM

@imnasnainaec imnasnainaec marked this pull request as ready for review July 6, 2026 15:39
@imnasnainaec imnasnainaec self-assigned this Jul 6, 2026

@hahn-kev hahn-kev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

while we're doing this should we also introduce a base data dir like we have in the maui kernel? That would certainly simplify configuration and setting paths that we're doing today.

Up to you, if we're happy with how it works today then I'm fine to merge this.

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

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FwLiteWeb state is binary-relative, so every Platform.Bible extension update would orphan it

2 participants