fix(file): deduplicate book files and protect source library root in FileMoveService#294
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)booklore-api/src/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (2)📚 Learning: 2026-03-26T01:46:48.863ZApplied to files:
📚 Learning: 2026-03-23T18:36:05.843ZApplied to files:
🔇 Additional comments (5)
📝 WalkthroughWalkthroughFileMoveService is updated to fix two bugs: deduplicating BookFileEntity lists before iteration to prevent duplicate processing failures, and adding the source library root path to the cleanup boundary set to prevent directory traversal above intended limits during cross-library moves. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
|
Thank you for this, both changes are very welcome from me! |
…ileMoveService (grimmory-tools#294) Co-authored-by: msmouse <git@dsmouse.com>
…ileMoveService (grimmory-tools#294) Co-authored-by: msmouse <git@dsmouse.com>
…ileMoveService (#294) Co-authored-by: msmouse <git@dsmouse.com>
…ileMoveService (#294) Co-authored-by: msmouse <git@dsmouse.com>
…ileMoveService (grimmory-tools#294) Co-authored-by: msmouse <git@dsmouse.com>
Fixes #293
Changes
FileMoveService
Two bugs fixed in both processSingleMove and moveBookToMatchLibraryPattern:
Duplicate BookFileEntity entries — getBookFiles() can return duplicates from the Hibernate lazy collection. Added .stream().distinct().toList() before iterating, so validation, staging, commit, and DB update loops each see each file exactly once.
libraryRoots missing source library — libraryRoots was built only from the target library's paths. On a cross-library move the source library root was absent, giving deleteEmptyParentDirsUpToLibraryFolders no stop boundary on the source side. Fixed by adding the source library path to the set before cleanup.
Summary by CodeRabbit