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

remove child shares #1000

Merged
merged 1 commit into from
Apr 14, 2022
Merged

remove child shares #1000

merged 1 commit into from
Apr 14, 2022

Conversation

ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Apr 6, 2022

1000!

Issue:

  • userA shares a first file to a Circle (including userA and userB),
  • userB leaves the share,
  • Circle is destroyed, a new Circle is created (including userA and userB)
  • Sharing the same file.

Fix:

  • split getUserShares from a single user to a circle and getAllShares to a circle
  • when a circle is deleted, or when a member is removed, get affected shares ids
  • get orphans on a maintenance process
  • delete all shares and child based on ids.

The request that get all orphan shares, based on parent not null and entry with id=parent exists:

SELECT `sh`.`id`, `sh`.`share_type`, `sh`.`share_with`, `sh`.`uid_owner`, `sh`.`uid_initiator`, `sh`.`parent`, `sh`.`item_type`, `sh`.`item_source`, `sh`.`item_target`, `sh`.`file_source`, `sh`.`file_target`, `sh`.`permissions`, `sh`.`stime`, `sh`.`accepted`, `sh`.`expiration`, `sh`.`token`, `sh`.`mail_send` FROM `oc_share` `sh` LEFT JOIN `oc_share` `p` ON `p`.`id` = `sh`.`parent` WHERE (`sh`.`share_type` = 7) AND (`sh`.`parent` IS NOT NULL) AND (`p`.`id` IS NULL)

The request that drop shares and child based on an array of ids:

DELETE FROM `oc_share` WHERE (`share_type` = 7) AND ((`id` IN ('6')) OR (`parent` IN ('6')))

@ArtificialOwl
Copy link
Member Author

/backport to stable23

@ArtificialOwl
Copy link
Member Author

/backport to stable22

@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2022

Codecov Report

Merging #1000 (029f286) into master (8589063) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

❗ Current head 029f286 differs from pull request most recent head 7315739. Consider uploading reports for the commit 7315739 to get more accurate results

@@             Coverage Diff             @@
##             master   #1000      +/-   ##
===========================================
- Coverage      0.70%   0.69%   -0.01%     
- Complexity     5735    5743       +8     
===========================================
  Files           290     290              
  Lines         19822   19860      +38     
===========================================
  Hits            139     139              
- Misses        19683   19721      +38     
Impacted Files Coverage Δ
lib/Db/ShareWrapperRequest.php 0.00% <0.00%> (ø)
lib/Listeners/Files/DestroyingCircle.php 0.00% <0.00%> (ø)
lib/Listeners/Files/MembershipsRemoved.php 0.00% <0.00%> (ø)
lib/Service/MaintenanceService.php 0.00% <0.00%> (ø)
lib/Service/MembershipService.php 0.00% <0.00%> (ø)
lib/Service/ShareWrapperService.php 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 459d504...7315739. Read the comment docs.

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl merged commit bc0484b into master Apr 14, 2022
@delete-merged-branch delete-merged-branch bot deleted the fix/noid/remove-child-shares branch April 14, 2022 15:17
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.

3 participants