Skip to content

fix: extend search paths for app version on Linux systems#3399

Closed
marcnause wants to merge 2 commits into
fossasia:mainfrom
marcnause:issue3398
Closed

fix: extend search paths for app version on Linux systems#3399
marcnause wants to merge 2 commits into
fossasia:mainfrom
marcnause:issue3398

Conversation

@marcnause

@marcnause marcnause commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #3398

Changes

  • added new element to array of paths which are used to search file which contains app version on Linux systems

Screenshots / Recordings

N/A

Checklist:

  • No hard coding: I have used values from constants.dart or localization files instead of hard-coded values.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have formatted the code using dart format or the IDE formatter.
  • Code analysis: My code passes checks run in flutter analyze and tests run in flutter test.

Summary by Sourcery

Extend Linux app version resolution to search an additional shared installation path and cover it with tests.

Bug Fixes:

  • Ensure the app can read its version from a shared /usr installation path on Linux when other locations are missing.

Tests:

  • Add a test verifying that the Linux version resolver reads version.json from the default package path and combines it with the build number.

Copilot AI review requested due to automatic review settings July 5, 2026 14:19
@sourcery-ai

sourcery-ai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Extends the Linux app version resolution logic by adding a system-wide shared directory search path and adds a test to cover the new default package path behavior.

Flow diagram for extended Linux app version search paths

flowchart TD
  start[_loadLinuxBundleVersion]
  start --> p1["Check ${executableParent.path}/data/flutter_assets/version.json"]
  p1 -->|not found| p2["Check ${executableParent.parent.path}/share/pslab/flutter_assets/version.json"]
  p2 -->|not found| p3["Check /usr/share/pslab/flutter_assets/version.json"]
  p1 -->|found| success["Return version from candidatePaths"]
  p2 -->|found| success
  p3 -->|found| success
Loading

File-Level Changes

Change Details Files
Extend Linux version resolution to search a system-wide shared directory for version metadata.
  • Add '/usr/share/pslab/flutter_assets/version.json' as an additional candidate path when loading the Linux bundle version.
  • Keep existing search order by appending the new system-wide path after the existing package-relative paths.
lib/others/about_us_version_resolver.dart
Add test coverage for version resolution using the default package data path on Linux.
  • Introduce a test that simulates a Linux environment with a version.json file under the executable's data/flutter_assets directory.
  • Use IOOverrides and a temporary version.json file to verify resolveAboutUsVersion returns the combined version and build number string from this path.
test/about_us_screen_version_test.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#3398 Ensure the app displays the correct version (not the fallback 1.0.0) when installed from a Debian/Linux .deb package by correctly locating and reading the version.json file.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The newly added absolute path (/usr/share/pslab/flutter_assets/version.json) is hard-coded; consider moving it to a constant or configuration so it can be managed centrally and adjusted per distro/environment.
  • If multiple installation layouts are possible, you may want to derive the extra search path from the executable location or XDG conventions rather than assuming /usr/share/pslab, to avoid failures on nonstandard installs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The newly added absolute path (`/usr/share/pslab/flutter_assets/version.json`) is hard-coded; consider moving it to a constant or configuration so it can be managed centrally and adjusted per distro/environment.
- If multiple installation layouts are possible, you may want to derive the extra search path from the executable location or XDG conventions rather than assuming `/usr/share/pslab`, to avoid failures on nonstandard installs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@marcnause marcnause changed the title extend search paths for app version on Linux systems fix: extend search paths for app version on Linux systems Jul 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes incorrect “fallback” app version display on Linux (notably Debian .deb installs) by extending the Linux-side lookup for the bundled version.json metadata when package_info_plus doesn’t provide a version.

Changes:

  • Added an additional system-wide lookup path for version.json on Linux (/usr/share/pslab/flutter_assets/version.json).

Comment thread lib/others/about_us_version_resolver.dart
@marcnause marcnause marked this pull request as draft July 5, 2026 14:22
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Build Status

Build successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/28744501713/artifacts/8092928507.

Screenshots

Android Screenshots
iPhone Screenshots
iPad Screenshots

@marcnause marcnause marked this pull request as ready for review July 5, 2026 14:48
Copilot AI review requested due to automatic review settings July 5, 2026 14:48
@marcnause marcnause requested a review from CloudyPadmal July 5, 2026 14:49

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The newly added /usr/share/pslab/flutter_assets/version.json path is hard-coded; consider building it using Platform.pathSeparator or a shared constant to keep path handling consistent and avoid platform-specific literals.
  • In the new Linux version resolution test, the executable and version file paths are manually concatenated as string literals; refactor to reuse the same path construction logic as the production code to reduce duplication and keep the test aligned with real path handling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The newly added `/usr/share/pslab/flutter_assets/version.json` path is hard-coded; consider building it using `Platform.pathSeparator` or a shared constant to keep path handling consistent and avoid platform-specific literals.
- In the new Linux version resolution test, the executable and version file paths are manually concatenated as string literals; refactor to reuse the same path construction logic as the production code to reduce duplication and keep the test aligned with real path handling.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment on lines +60 to +73
test('uses version in default path from package', () async {
final executablePath =
'${Platform.pathSeparator}usr${Platform.pathSeparator}bin${Platform.pathSeparator}'
'pslab';
final versionFile = File(
'${Platform.pathSeparator}usr${Platform.pathSeparator}bin${Platform.pathSeparator}'
'data${Platform.pathSeparator}flutter_assets${Platform.pathSeparator}'
'version.json',
);

IOOverrides.runZoned(() async {
await versionFile.create(recursive: true);
await versionFile.writeAsString('{"version":"6.5.3"}');

Comment on lines 57 to 61
final candidatePaths = <String>[
'${executableParent.path}/data/flutter_assets/version.json',
'${executableParent.parent.path}/share/pslab/flutter_assets/version.json',
'/usr/share/pslab/flutter_assets/version.json',
];
@marcnause marcnause marked this pull request as draft July 5, 2026 14:54
@marcnause marcnause closed this Jul 5, 2026
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.

app displays fallback version if installed from deb package

2 participants