Conversation
905c971 to
4a06710
Compare
resolution (was duplicated across two classes) - Change FolderService#deleteFolder to call TrashService#moveToTrash - Add a check to prevent FolderService from deleting the entire user root directory - Add FileUtil tests
4a06710 to
ceca7e0
Compare
|
It should be noted, currently this produces a circular dependency between the TrashService and the FolderService, so it may not compile. Will review and rework. |
There was a problem hiding this comment.
Agent review
Two blocking problems in FolderService.deleteFolder: a circular bean dependency with TrashService (app won't start) and a trash call that can't work on directories or per-entry paths. Existing tests also still use the old signature. See inline comments.
Generated by Pull Request Review for #158 · copilot · auto · 21.6 AIC · ⌖ 5.07 AIC · ⊞ 7K
| private final JaroWinklerSimilarity jaroWinkler = new JaroWinklerSimilarity(); | ||
| private final TrashService trashService; | ||
|
|
||
| public FolderService(TrashService trashService) { |
There was a problem hiding this comment.
Circular dependency: TrashService is @RequiredArgsConstructor with a FolderService folderService field (and calls folderService.validatePath). Injecting TrashService into FolderService via constructor creates a cycle, so the Spring context fails to start (BeanCurrentlyInCreationException). The FolderService used to have no dependencies. Move the validation into FileUtil and have TrashService use it, or otherwise break the cycle.
| p -> { | ||
| try { | ||
| Files.delete(p); | ||
| trashService.moveToTrash(rootPathString, ownerId, relativeFolderPath); |
There was a problem hiding this comment.
Wrong behaviour: this runs inside a per-path Files.walk(folder) loop but always passes relativeFolderPath (the folder, not p). TrashService.moveToTrash throws ResourceNotFoundException unless the source is a regular file, so deleting any folder fails on the first iteration (folder is not a regular file). Even if it worked, a folder with N entries would trigger N calls on the same path. Trash each regular file under its own relative path (rootPath.relativize(p)), then delete the remaining empty directories. The existing deleteFolder_* tests in FolderServiceTest still call the old 2-arg signature (compile error) and nothing covers the new behaviour, the root-folder check, or the trash move.
Summary
Still a DRAFT. TODO:
deleteFolder()Linked issue
Closes #155