Skip to content

Feat/fix issues for android app - #18

Merged
renjuashokan merged 2 commits into
mainfrom
feat/fix_issues_for_android_app
Dec 1, 2025
Merged

Feat/fix issues for android app#18
renjuashokan merged 2 commits into
mainfrom
feat/fix_issues_for_android_app

Conversation

@renjuashokan

@renjuashokan renjuashokan commented Dec 1, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor
    • Improved path handling so file paths, parent directories and relative paths are computed consistently with project root semantics.
  • Bug Fixes / Reliability
    • Added safer metadata handling with explicit error paths for size retrieval and an OS-specific fallback for creation time, reducing panics and improving stability.

✏️ Tip: You can customize this high-level summary in your review settings.

@renjuashokan renjuashokan self-assigned this Dec 1, 2025
@coderabbitai

coderabbitai Bot commented Dec 1, 2025

Copy link
Copy Markdown

Walkthrough

The FileInfo::from_path API was extended to accept a third root_dir parameter. Call sites in file handlers were updated to pass config.root_dir. Path computations (full_name, parent_dir, rel_path), size/error handling, and created_time fallback logic were adjusted to use both current and root directories.

Changes

Cohort / File(s) Change Summary
Model: FileInfo signature & logic
filepi-server/src/models/file_info.rs
from_path signature changed to from_path(absolute_path, current_dir, root_dir). Computes full_name relative to current_dir, derives parent_dir and rel_path relative to root_dir, adds explicit error handling for size retrieval, and a Unix-specific fallback for created_time.
Handlers: call-site updates
filepi-server/src/handlers/files.rs
All FileInfo::from_path invocations updated to pass &config.root_dir as the third argument. Replaced prior unwrap() uses with map_err(...)? (consistent InternalError mapping) where applicable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Areas to review:
    • Correctness of path prefix stripping/normalization when deriving full_name, parent_dir, and rel_path
    • Error handling around size retrieval and the mapped AppError::InternalError usage
    • Unix-specific created_time fallback behavior and portability implications
    • Consistency across all updated call sites in files.rs

Poem

I hop through roots and paths anew,
Three arguments guide each view,
Sizes checked, and times fall back,
Parent, rel — no lost track,
A rabbit’s hop, precise and true 🐇📂

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Feat/fix issues for android app' is vague and generic, using non-descriptive terms that don't convey meaningful information about the actual changeset. Consider a more specific title like 'Refactor FileInfo::from_path to include root_dir parameter' that accurately describes the technical changes made.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/fix_issues_for_android_app

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24a148c and d03db30.

📒 Files selected for processing (2)
  • filepi-server/src/handlers/files.rs (3 hunks)
  • filepi-server/src/models/file_info.rs (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
filepi-server/src/handlers/files.rs (1)
filepi-server/src/models/file_info.rs (1)
  • from_path (22-107)
🔇 Additional comments (4)
filepi-server/src/handlers/files.rs (1)

104-109: LGTM!

The FileInfo::from_path call correctly passes the new root_dir parameter with proper error handling.

filepi-server/src/models/file_info.rs (3)

22-29: LGTM!

The function signature correctly adds the root_dir parameter to enable root-relative path computations. The generic bounds and parameter extraction are appropriate.


61-70: LGTM!

The Unix-specific fallback to ctime is a reasonable approach for systems where created() is not available. The conditional compilation is properly used.


84-93: LGTM!

The path computations correctly use root_dir as the reference point for parent_dir and rel_path. The use of Option for graceful handling of strip_prefix failures is appropriate.

Comment thread filepi-server/src/handlers/files.rs Outdated
Comment thread filepi-server/src/handlers/files.rs Outdated
Comment on lines +38 to +43
// full_name should be relative to current_dir (without leading /)
let full_name = path
.strip_prefix(current)
.ok()
.map(|rel| rel.to_string_lossy().to_string())
.unwrap_or_else(|| String::from(path.to_str().unwrap()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Consider handling non-UTF-8 paths more gracefully.

The fallback uses .unwrap() which will panic if the path contains invalid UTF-8 sequences. While rare, this could occur with certain filesystem edge cases.

Apply this diff for safer error handling:

         let full_name = path
             .strip_prefix(current)
             .ok()
             .map(|rel| rel.to_string_lossy().to_string())
-            .unwrap_or_else(|| String::from(path.to_str().unwrap()));
+            .unwrap_or_else(|| path.to_string_lossy().to_string());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// full_name should be relative to current_dir (without leading /)
let full_name = path
.strip_prefix(current)
.ok()
.map(|rel| rel.to_string_lossy().to_string())
.unwrap_or_else(|| String::from(path.to_str().unwrap()));
// full_name should be relative to current_dir (without leading /)
let full_name = path
.strip_prefix(current)
.ok()
.map(|rel| rel.to_string_lossy().to_string())
.unwrap_or_else(|| path.to_string_lossy().to_string());
🤖 Prompt for AI Agents
In filepi-server/src/models/file_info.rs around lines 38 to 43, the fallback
branch uses path.to_str().unwrap() which will panic on non-UTF-8 paths; replace
the unwrap with a safe conversion (e.g., use path.to_string_lossy().to_string()
or otherwise handle the non-UTF-8 case) so the code never panics on invalid
UTF-8; optionally log or propagate an error when lossy conversion occurs if you
need to track that condition.

@renjuashokan
renjuashokan force-pushed the feat/fix_issues_for_android_app branch from d03db30 to 92f6b0b Compare December 1, 2025 04:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
filepi-server/src/handlers/files.rs (1)

292-297: search handler fix looks good; consider DRYing up the repeated error mapping

This hunk correctly uses &full_path as the directory context, passes &config.root_dir, and handles FileInfo::from_path errors consistently with the other handlers. If this pattern keeps repeating, you might later extract a small helper (e.g. fn build_file_info(...) -> Result<FileInfo, AppError>) to avoid duplicating the map_err block in get_files, get_videos, and search.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d03db30 and 92f6b0b.

📒 Files selected for processing (2)
  • filepi-server/src/handlers/files.rs (3 hunks)
  • filepi-server/src/models/file_info.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • filepi-server/src/models/file_info.rs
🧰 Additional context used
🧬 Code graph analysis (1)
filepi-server/src/handlers/files.rs (1)
filepi-server/src/models/file_info.rs (1)
  • from_path (22-107)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build Rust (arm64)
  • GitHub Check: Build Blazor Frontend
🔇 Additional comments (2)
filepi-server/src/handlers/files.rs (2)

104-109: Updated FileInfo construction and error handling in get_files looks correct

FileInfo::from_path is now called with (absolute_path, current_dir, root_dir) and errors are mapped into AppError::InternalError with logging and ?, which aligns with the new API and avoids panics.


199-204: get_videos no longer panics on FileInfo errors

Replacing the previous .unwrap() with map_err(...)? and passing (&file_path, &full_path, &config.root_dir) correctly integrates the new FileInfo::from_path signature and ensures failures don’t crash the handler.

@renjuashokan
renjuashokan merged commit f2f479e into main Dec 1, 2025
8 checks passed
@renjuashokan
renjuashokan deleted the feat/fix_issues_for_android_app branch December 1, 2025 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant