Skip to content

fix(files_sharing): merge added share into existing mount of the same node - #67750

Open
susnux wants to merge 1 commit into
masterfrom
fix/share-merge-added-share-mount
Open

susnux wants to merge 1 commit into
masterfrom
fix/share-merge-added-share-mount

Conversation

@susnux

@susnux susnux commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a user receives another share for a node they already have a share mount for (e.g. first via a group, later directly), both shares should end up in one mount at the existing target. ShareRecipientUpdater::updateForAddedShare() instead validated the new share on its own and added a second mount at its default target to the mount cache. The shares were only merged (MountProvider::buildSuperShares() → adjustTarget()) on the next full filesystem setup. Until then the recipient saw the node twice, and a target they had renamed seemed to come back.

If the recipient already has a share mount rooted at the same node, updateForAddedShare() now falls back to updateForUser(), which groups the shares and moves the new share to the existing target.

On master this is mostly hidden because every login without a session (e.g. each basic auth request) does a full setup. #54803 removes that, and sharing-v1-part3.feature:307 ("Merging shares for recipient when shared from outside with group then user and recipient renames in between") then fails without this fix.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

… node

When a user receives another share for a node they already have a share
mount for, for example from a group and then directly, the shares belong
to one mount at the existing target. The added share was instead
validated on its own and registered as a second mount at its default
target. The shares were only merged on the next full filesystem setup,
so until then the recipient saw the node twice, and a target the
recipient had renamed came back.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux

susnux commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable35

@susnux
susnux marked this pull request as ready for review December 6, 2026 01:48
@susnux
susnux requested a review from a team as a code owner December 6, 2026 01:48
@susnux
susnux requested review from icewind1991, pabzm, provokateurin and vlotysh and removed request for a team and pabzm December 6, 2026 01:48
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Possible performance regression detected

Show Output
7 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
= /remote.php/dav/files/test/new_file.txt
≠ /remote.php/dav/files/test/new_file.txt with 7 queries added
  - UPDATE "oc_filecache" SET "size" = :dcValue4 WHERE ("fileid" = :dcValue1) AND ("storage" = :dcValue2) AND (("size" <> :dcValue3) OR ("size" IS NULL))
  - UPDATE "oc_filecache" SET "size" = :dcValue4 WHERE ("fileid" = :dcValue1) AND ("storage" = :dcValue2) AND (("size" <> :dcValue3) OR ("size" IS NULL))
  - SELECT "path" FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("fileid" = :dcValue2)
  - SELECT "path" FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("fileid" = :dcValue2)
  + SELECT "storage", "path", "mimetype" FROM "oc_filecache" WHERE "fileid" = :dcValue1
  + SELECT "storage_id", "root_id", "user_id", "mount_point", "mount_id", "f"."path", "mount_provider_class" FROM "oc_mounts" "m" INNER JOIN "oc_filecache" "f" ON "m"."root_id" = "f"."fileid" WHERE ("m"."storage_id" = :dcValue1) AND ("f"."storage" = :dcValue2) AND (("f"."fileid" = :dcValue3) OR ("f"."path" = '') OR (("f"."path" || :dcValue4) = SUBSTR(:dcValue5, :dcValue6, LENGTH("f"."path") + :dcValue7))) AND ("user_id" = :dcValue8)
  + SELECT "filecache"."fileid", "storage", "path", "path_hash", "filecache"."parent", "filecache"."name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "filecache"."etag", "filecache"."permissions", "checksum", "unencrypted_size", "metadata_etag", "creation_time", "upload_time", "meta"."json" AS "meta_json", "meta"."sync_token" AS "meta_sync_token" FROM "oc_filecache" "filecache" LEFT JOIN "oc_filecache_extended" "fe" ON "filecache"."fileid" = "fe"."fileid" LEFT JOIN "oc_files_metadata" "meta" ON "filecache"."fileid" = "meta"."file_id" WHERE ("filecache"."fileid" = :dcValue1) AND ("storage" = :dcValue2)
  + DELETE FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("fileid" = :dcValue2)
  + DELETE FROM "oc_filecache_extended" WHERE "fileid" = :dcValue1
  + SELECT "file_id", "json", "sync_token" FROM "oc_files_metadata" WHERE "file_id" IN (:dcValue1)
  + DELETE FROM "oc_files_metadata" WHERE "file_id" IN (:dcValue1)
  + DELETE FROM "oc_files_metadata_index" WHERE "file_id" IN (:dcValue1)
  + SELECT "fileid" FROM "oc_filecache" WHERE ("storage" = :dcValue1) AND ("path_hash" = :dcValue2)
  + UPDATE "oc_file_locks" SET "lock" = :dcValue1, "ttl" = :dcValue2 WHERE ("key" = :dcValue3) AND ("lock" = :dcValue4)
  + SELECT "filecache"."fileid", "storage", "path", "path_hash", "filecache"."parent", "filecache"."name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "filecache"."etag", "filecache"."permissions", "checksum", "unencrypted_size", "metadata_etag", "creation_time", "upload_time", "meta"."json" AS "meta_json", "meta"."sync_token" AS "meta_sync_token" FROM "oc_filecache" "filecache" LEFT JOIN "oc_filecache_extended" "fe" ON "filecache"."fileid" = "fe"."fileid" LEFT JOIN "oc_files_metadata" "meta" ON "filecache"."fileid" = "meta"."file_id" WHERE ("path_hash" = :dcValue1) AND ("storage" = :dcValue2)
= ./occ profiler:list

This branch has not been deployed

No deployments
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.

2 participants