-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(files_sharing): Fix stray groups not being cleaned up from shares when deleted #51012
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
55e2f6a
fix(files_sharing): Fix stray groups not being cleaned up from shares…
Pytal 026233f
chore(files_sharing): Update autoloaders
Pytal 7455bea
test(files_sharing): Deleted groups are removed from shares
Pytal 35b73fe
chore: compile assets
Pytal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Files_Sharing\Listener; | ||
|
|
||
| use OCP\EventDispatcher\Event; | ||
| use OCP\EventDispatcher\IEventListener; | ||
| use OCP\Group\Events\GroupDeletedEvent; | ||
| use OCP\Share\IManager as IShareManager; | ||
|
|
||
| /** @template-implements IEventListener<GroupDeletedEvent> */ | ||
| class GroupDeletedListener implements IEventListener { | ||
| public function __construct( | ||
| private IShareManager $shareManager, | ||
| ) { | ||
| } | ||
|
|
||
| public function handle(Event $event): void { | ||
| if (!($event instanceof GroupDeletedEvent)) { | ||
| return; | ||
| } | ||
| $group = $event->getGroup(); | ||
| $this->shareManager->groupDeleted($group->getGID()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import type { User } from '@nextcloud/cypress' | ||
|
|
||
| import { createShare, openSharingPanel } from './FilesSharingUtils.ts' | ||
|
|
||
| describe('files_sharing: Group deleted', { testIsolation: true }, () => { | ||
| let user: User | ||
| let file: string | ||
| let group1: string | ||
| let group2: string | ||
|
|
||
| before(() => { | ||
| cy.createRandomUser().then((randomUser) => { | ||
| user = randomUser | ||
|
|
||
| file = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt' | ||
| cy.uploadContent(user, new Blob(['share to user'], { type: 'text/plain' }), 'text/plain', `/${file}`) | ||
|
|
||
| group1 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
| group2 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) | ||
| cy.runOccCommand(`group:add ${group1}`) | ||
| cy.runOccCommand(`group:add ${group2}`) | ||
|
|
||
| cy.login(user) | ||
| cy.visit('/apps/files') | ||
| createShare(file, group1) | ||
| createShare(file, group2) | ||
| }) | ||
| }) | ||
|
|
||
| it('deleted groups are removed from shares', () => { | ||
| cy.login(user) | ||
| cy.visit('/apps/files') | ||
|
|
||
| openSharingPanel(file) | ||
| cy.get('[data-cy-files-sharing-internal-list]').within(() => { | ||
| // see that file is shared with group1 | ||
| cy.contains('li', `${group1} (group)`) | ||
| .should('exist') | ||
| // see that file is also shared with group2 | ||
| cy.contains('li', `${group2} (group)`) | ||
| .should('exist') | ||
| }) | ||
|
|
||
| // delete group1 | ||
| cy.runOccCommand(`group:delete ${group1}`) | ||
|
|
||
| // reload the page | ||
| cy.reload() | ||
|
|
||
| openSharingPanel(file) | ||
| cy.get('[data-cy-files-sharing-internal-list]').within(() => { | ||
| // see that file is no longer shared with the deleted group1 | ||
| cy.contains('li', `${group1} (group)`) | ||
| .should('not.exist') | ||
| // see that file is still shared with group2 | ||
| cy.contains('li', `${group2} (group)`) | ||
| .should('exist') | ||
| }) | ||
| }) | ||
| }) | ||
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 2212-2212.js.license |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For PHP code its more common to add integration tests (behat) that Cypress.