fix(api): check legacy tools path for binaries#146
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughExtracted search-path construction into a new private getSystemSearchPath(); findSystemFile now iterates candidates from that path and returns the resolved candidate as an absolute, normalized Path; added tests that statically mock Files.isRegularFile to exercise primary and fallback resolution. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
41b65b2 to
0df7f2e
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@booklore-api/src/main/java/org/booklore/util/FileService.java`:
- Around line 171-174: findSystemFile currently returns Path objects like
possiblePath that may be relative; update the return to convert the resolved
Path to an absolute, normalized path by calling .toAbsolutePath().normalize() on
possiblePath before returning to ensure downstream binary execution is
cwd-independent (refer to the possiblePath variable in findSystemFile).
- Around line 151-168: The method getSystemSearchPath and its caller
findSystemFile currently hardcode ":" and build a relative "bin" path; change
them to use platform-safe File.pathSeparator instead of ":" and construct the
local bin path from appProperties.getPathConfig() (e.g.,
Path.of(appProperties.getPathConfig(), "bin").toString()) so both "bin" and
legacyToolsPath are absolute/consistent, build the final search string by
joining localBin, legacyToolsPath and System.getenv("PATH") (handling null), and
update findSystemFile to split using File.pathSeparator (or
Pattern.quote(File.pathSeparator)) rather than ":".
In `@booklore-api/src/test/java/org/booklore/util/FileServiceTest.java`:
- Around line 312-339: The tests assume the local-bin path is "bin/example"
relative to cwd, which masks ignoring appProperties.getPathConfig(); update both
tests so the expected Path is built from the configured local-bin path instead
of a hardcoded "bin" string: use the Path returned by
appProperties.getPathConfig().getLocalBin() (or the appropriate accessor on
appProperties.getPathConfig()) and resolve "example" against it, keep the
Files.isRegularFile mocking the same, and assert that
fileService.findSystemFile("example") equals that configured-path result.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f733c3e7-26ae-416a-8ccb-7df98193131f
📒 Files selected for processing (2)
booklore-api/src/main/java/org/booklore/util/FileService.javabooklore-api/src/test/java/org/booklore/util/FileServiceTest.java
There was a problem hiding this comment.
♻️ Duplicate comments (1)
booklore-api/src/main/java/org/booklore/util/FileService.java (1)
167-168:⚠️ Potential issue | 🟠 MajorUse the same separator for split as for path construction.
getSystemSearchPath()builds withFile.pathSeparator, butfindSystemFile()still splits on":". This makes parsing inconsistent and breaks compatibility on non-colon-separated environments.Suggested fix
+import java.util.regex.Pattern; ... - String[] searchPaths = getSystemSearchPath().split(":"); + String[] searchPaths = getSystemSearchPath().split(Pattern.quote(File.pathSeparator));#!/bin/bash set -euo pipefail # Verify current separator construction vs parsing behavior. nl -ba booklore-api/src/main/java/org/booklore/util/FileService.java | sed -n '151,175p' rg -n 'File\.pathSeparator|getSystemSearchPath\(\)\.split\(":\"\)' booklore-api/src/main/java/org/booklore/util/FileService.java # Expected: # - path is built using File.pathSeparator # - split should use Pattern.quote(File.pathSeparator), not ":"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@booklore-api/src/main/java/org/booklore/util/FileService.java` around lines 167 - 168, The findSystemFile method currently splits the search path with a hardcoded ":" which mismatches how getSystemSearchPath builds the path using File.pathSeparator; update findSystemFile to split on the actual system separator (use Pattern.quote(File.pathSeparator) or otherwise derive the separator from File.pathSeparator) so parsing is consistent across platforms (locate the split call in findSystemFile and replace the literal ":" with a split that uses File.pathSeparator).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@booklore-api/src/main/java/org/booklore/util/FileService.java`:
- Around line 167-168: The findSystemFile method currently splits the search
path with a hardcoded ":" which mismatches how getSystemSearchPath builds the
path using File.pathSeparator; update findSystemFile to split on the actual
system separator (use Pattern.quote(File.pathSeparator) or otherwise derive the
separator from File.pathSeparator) so parsing is consistent across platforms
(locate the split call in findSystemFile and replace the literal ":" with a
split that uses File.pathSeparator).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bc535fd6-e6f4-431a-b09e-69c830eaeb53
📒 Files selected for processing (1)
booklore-api/src/main/java/org/booklore/util/FileService.java
the kepubify / ffprobe binaries may be on disk but they're in the "data" directory under `tools` rather than under the current directory
8ae6629 to
1de7044
Compare
|
Rebased and cleaned up a few things. |
balazs-szucs
left a comment
There was a problem hiding this comment.
Thank you, looks good!
* develop: fix(entrypoint): ensure books directory exists and is writable by the target user (grimmory-tools#119) fix(metadata): fix metadata fetching relying for filename "first" instead of better fields like ISBN in Goodreads/Bookdrop (grimmory-tools#85) chore(build): migrate Gradle build scripts from Groovy to Kotlin DSL (grimmory-tools#100) perf(ui): captures some low hanging fruit around excessive re-renders in the app (grimmory-tools#158) fix(api): check legacy tools path for binaries (grimmory-tools#146)
the kepubify / ffprobe binaries may be on disk but they're in the "data" directory under `tools` rather than under the current directory
the kepubify / ffprobe binaries may be on disk but they're in the "data" directory under `tools` rather than under the current directory
the kepubify / ffprobe binaries may be on disk but they're in the "data" directory under `tools` rather than under the current directory
the kepubify / ffprobe binaries may be on disk but they're in the "data" directory under `tools` rather than under the current directory
Description
the kepubify / ffprobe binaries may be on disk but they're in the "data"
directory under
toolsrather than under the current directoryin some cases, like proxmox or other manual installs, this helps make the
transition to grimmory easier
Changes
Summary by CodeRabbit
Internal Improvements
Tests