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

Fixes #31849 - delete thumbnails on write hooks #31853

Merged
merged 1 commit into from
Jun 21, 2018
Merged

Conversation

DeepDiver1975
Copy link
Member

@DeepDiver1975 DeepDiver1975 commented Jun 21, 2018

Description

Thumbnails only got deleted on delete - not for write events.
On write thumbnails need to be deleted so that a future GET will recreate them as needed.

Related Issue

Fixes #31849

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@PVince81
Copy link
Contributor

@DeepDiver1975 did you find out why it worked in v10.0.8 ? Are we not triggering the same hooks with the new versions code ?

@DeepDiver1975
Copy link
Member Author

@DeepDiver1975 did you find out why it worked in v10.0.8 ? Are we not triggering the same hooks with the new versions code ?

I completly rewired the hook processing and missed this case. Hail to stupid hooks and the lack of tests .....

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

unit tests possible ?

return;
$user = isset($args['user']) ? $args['user'] : \OC_User::getUser();
if ($user === false) {
$user = Filesystem::getOwner($path);
Copy link
Contributor

Choose a reason for hiding this comment

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

what user do we receive here in the following scenario:

  1. admin sets up system-wide ext storage "/sftp" with sharing enabled
  2. user1 shares folder "sftp/test" with public link
  3. log out
  4. anonymous user opens link and upload+overwrites file

There is a slight risk that you'll get null here as the storage has no owner since it's system-wide. In other code paths we somehow hackily resolve this to the sharer.

Copy link
Member Author

Choose a reason for hiding this comment

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

let me return in case $user is null and we will see how far we get

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me know when you are finished editing the "real code" and I will quickly re-run the 3 scenarios in the issue report.
After that, you can write unit tests all you like, and it won't make a difference to the run-time behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no need in checking if Filesystem::getOwner is returning a valid user - it will always be a user (maybe not the correct on - but this is a different story).
An exception will be thrown if there is no owner - so we will stop execution of the hook listener.

no further changes from my pov - let's merge this and I take care about the backport

@phil-davis
Copy link
Contributor

I saw that owner code, and it made me try sharing and editing.

  1. as "user1" create folder "test" and in it put "testfile.txt" with content "owner" - thumbnail says "owner" - good
  2. share folder "test" with "user2"
  3. as "user2", edit "testfile.txt" and put content "user2 text"
  • thumbnail displayed to "user2" is not updated
  1. login as "user1" - the thumbnail displays "user2 text" - good
  2. login as "user2" - the thumbnail still displays "owner" ???

so we have 2 different thumbnails stored somewhere.

@PVince81
Copy link
Contributor

@phil-davis are these test scenarios also a regression ?

@phil-davis
Copy link
Contributor

phil-davis commented Jun 21, 2018

Hmmm - in 10.0.8 the scenario is "reversed". When "user2" edits the file in the received share, the thumbnail for "user2" is updated. But the thumbnail for "user1" (the owner) stays out-of-date.

In 10.0.9RC1 nether user sees an updated thumbnail.

So you can choose which set of symptoms you "like" - 10.0.8 10.0.9RC1 or this PR - they are all different.

@phil-davis
Copy link
Contributor

I guess there is some underlying issue that is allowing the possibility for a file to have a thumbnail generated and stored multiple times, under different users. If that is so, then I guess it is a whole other can-of-worms that has been there "a long time".

@codecov
Copy link

codecov bot commented Jun 21, 2018

Codecov Report

Merging #31853 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #31853      +/-   ##
============================================
- Coverage     63.27%   63.27%   -0.01%     
- Complexity    18476    18479       +3     
============================================
  Files          1161     1161              
  Lines         69371    69377       +6     
  Branches       1261     1261              
============================================
  Hits          43895    43895              
- Misses        25106    25112       +6     
  Partials        370      370
Flag Coverage Δ Complexity Δ
#javascript 52.47% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 64.5% <0%> (-0.01%) 18479 <0> (+3)
Impacted Files Coverage Δ Complexity Δ
lib/private/Preview.php 79.4% <0%> (-1.03%) 168 <0> (+3)

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 2df5b94...aeeb732. Read the comment docs.

@phil-davis
Copy link
Contributor

phil-davis commented Jun 21, 2018

As discussed in chat, there are issues with file sharing and keeping thumbnails in-sync when sharer and sharee(s) edit a file. Multiple thumbnails are getting generated under various conditions. That has been the case "for some time". The particular set of symptoms evident with this PR might be a little different to the symptoms when running 10.0.8, but the underlying general problem is common.

I will raise an issue for that, which needs to be addressed separately, not as a "quick fix for an RC".
Issue #31855

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

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

From a QA-testing point-of-view this is good.
All 3 scenarios detailed in the issue work with this code.

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍

@phil-davis
Copy link
Contributor

Backport stable10 #31865

@lock lock bot locked as resolved and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thumbnail not regenerated as file changes
4 participants