Skip to content

fix(FaceRoot): allow getChild to find face photos by plain filename#1536

Open
manuviens wants to merge 1 commit into
nextcloud:mainfrom
manuviens:fix/faceroot-getchild-plain-filename
Open

fix(FaceRoot): allow getChild to find face photos by plain filename#1536
manuviens wants to merge 1 commit into
nextcloud:mainfrom
manuviens:fix/faceroot-getchild-plain-filename

Conversation

@manuviens

Copy link
Copy Markdown

Problem

When Nextcloud Photos sends a MOVE request to merge faces, it references children by their basename only (e.g. photo.jpg), not by the internal {detectionId}-{filename} pattern. This means a MOVE to /recognize/{userId}/faces/{cluster}/photo.jpg fails with 404 because FaceRoot::getChild('photo.jpg') cannot find the child.

The server-side moveInto() would succeed, but the DAV layer returns 404 on the source lookup, causing Photos to display an error (TypeError in n.faceDetections.find(d => d.title === u)) even though the operation completed on the server.

Fix

Two fallback paths added to getChild():

  1. Cached-children path (when $this->children is already populated): after the primary match fails, iterate again and compare against $child->getFile()->getName().

  2. Direct-DB path (when cache is empty): guard with is_numeric($detectionId) before the numeric lookup to avoid breaking on plain filenames. If not numeric, query findByClusterId() and filter results by $file->getName() matching the requested basename.

Tested in production on Nextcloud 34 / Recognize 12.0.0. All MOVE operations return HTTP 201/204 and merges complete correctly.

When the Photos app sends a MOVE request, it references children by
their basename only (e.g. `photo.jpg`), not by the internal
`{detectionId}-{filename}` pattern that getChild() expected.

This caused a 404 on the source node for `unassigned-faces → faces`
moves and on named clusters for `faces → faces` reassignments, even
though the server-side moveInto() would succeed.

Fix:
- In the cached-children path, fall back to matching
  `$child->getFile()->getName()` when the primary
  `$child->getName()` match fails.
- In the direct-DB path, guard with `is_numeric($detectionId)`
  before the numeric lookup, then fall back to filtering detections
  by `findByClusterId` + filecache `getName()`.
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.

1 participant