Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add command to update re-share if shared-by user has been revoked #43025

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

luka-nextcloud
Copy link
Contributor

@luka-nextcloud luka-nextcloud commented Jan 22, 2024

Summary

Add command occ sharing:fix-broken-shares to fix the shares that were broken on transfer ownership.

Checklist

  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes
  • Documentation (manuals or wiki) has been updated or is not required
  • Backports requested where applicable (ex: critical bugfixes)

@luka-nextcloud luka-nextcloud added bug 3. to review Waiting for reviews labels Jan 22, 2024
@luka-nextcloud luka-nextcloud self-assigned this Jan 22, 2024
@luka-nextcloud
Copy link
Contributor Author

Another effected case by this issue:

  1. UserA share Folder1 to UserB
  2. UserB share Folder1 to UserC
  3. UserA revoke UserB
  4. UserA try to update sharing permission of UserC
    -> Error: Could not get proper share mount for . Failing since else the next calls are called with null

@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch 2 times, most recently from c298bf1 to 0828727 Compare February 5, 2024 18:28
@luka-nextcloud
Copy link
Contributor Author

@artonge I've updated as you requested, please check again.

Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

Can you add comments to clarify what each if group does?

I am also wondering if we could find this shares with the following query:

SELECT
	f.fileid,
	f.path,
	f.storage,
	s.id as share_id,
	s.uid_owner as share_owner,
	s.uid_initiator as share_initiator,
	s.share_with as share_recipient
FROM
	oc_filecache f
	JOIN oc_share s ON f.fileid = s.file_source
	AND s.uid_initiator NOT IN (
		SELECT
			user_id
		FROM
			oc_mounts m
		WHERE
			f.storage = m.storage_id
	)

If so, then we could have a background job to remove them every hour or so like https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/DeleteOrphanedSharesJob.php, which might be easier than the current solution.

lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
@luka-nextcloud
Copy link
Contributor Author

Can you add comments to clarify what each if group does?

I am also wondering if we could find this shares with the following query:

SELECT
	f.fileid,
	f.path,
	f.storage,
	s.id as share_id,
	s.uid_owner as share_owner,
	s.uid_initiator as share_initiator,
	s.share_with as share_recipient
FROM
	oc_filecache f
	JOIN oc_share s ON f.fileid = s.file_source
	AND s.uid_initiator NOT IN (
		SELECT
			user_id
		FROM
			oc_mounts m
		WHERE
			f.storage = m.storage_id
	)

If so, then we could have a background job to remove them every hour or so like https://github.com/nextcloud/server/blob/master/apps/files_sharing/lib/DeleteOrphanedSharesJob.php, which might be easier than the current solution.

@artonge It only works if the shared-by user refreshes his files list after his share has revoked. So, I don't think this query would do the job.

@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch 3 times, most recently from 007d650 to df7160f Compare April 1, 2024 08:13
@susnux susnux added this to the Nextcloud 30 milestone Apr 18, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from df7160f to 73fb85b Compare May 30, 2024 12:15
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/OrphanHelper.php Outdated Show resolved Hide resolved
@skjnldsv skjnldsv removed their request for review June 3, 2024 08:07
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from 7e64905 to cf9b02a Compare June 4, 2024 18:39
@luka-nextcloud luka-nextcloud requested review from artonge and come-nc June 4, 2024 18:40
apps/files_sharing/lib/OrphanHelper.php Outdated Show resolved Hide resolved
apps/files_sharing/lib/Command/FixBrokenShares.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
@luka-nextcloud luka-nextcloud requested a review from come-nc June 7, 2024 13:46
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
lib/private/Share20/Manager.php Outdated Show resolved Hide resolved
@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Oct 29, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from b23eafb to 5b01338 Compare November 7, 2024 18:44
@luka-nextcloud luka-nextcloud added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 7, 2024
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch 2 times, most recently from cc6c3dc to bff24d1 Compare November 13, 2024 18:59
@luka-nextcloud luka-nextcloud force-pushed the bugfix/error-on-reshare-after-transfer-ownership branch from bff24d1 to 2ca5191 Compare November 18, 2024 20:24
@come-nc come-nc merged commit ae7f9cb into master Nov 25, 2024
186 checks passed
@come-nc come-nc deleted the bugfix/error-on-reshare-after-transfer-ownership branch November 25, 2024 17:20
@juliusknorr juliusknorr changed the title fix: update re-share if shared-by user has been revoked fix: Add command to update re-share if shared-by user has been revoked Dec 2, 2024
@luka-nextcloud
Copy link
Contributor Author

/backport to stable28

@luka-nextcloud
Copy link
Contributor Author

/backport to stable29

@luka-nextcloud
Copy link
Contributor Author

/backport to stable30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
Status: ☑️ Done
Development

Successfully merging this pull request may close these issues.

[Bug]: Sub folder shares were broken on ownership transfer
6 participants