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

better handling of preview generation errors #4620

Merged
merged 4 commits into from
May 2, 2017
Merged

Conversation

icewind1991
Copy link
Member

Prevents failing hard when working with corrupted images

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label May 1, 2017
@icewind1991 icewind1991 added this to the Nextcloud 12.0 milestone May 1, 2017
@icewind1991 icewind1991 requested review from rullzer and MorrisJobke May 1, 2017 12:24
@mention-bot
Copy link

@icewind1991, thanks for your PR! By analyzing the history of the files in this pull request, we identified @butonic, @rullzer and @tanghus to be potential reviewers.

@MorrisJobke
Copy link
Member

Makes sense but I could not verify that it failed before. I took a document and renamed it to .png and triggered the occ preview:generate-all - before and after there is no error.

@icewind1991
Copy link
Member Author

You need an actual corrupted image, not just a wrongly named one

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

Makes sense!

@MorrisJobke
Copy link
Member

You need an actual corrupted image, not just a wrongly named one

Do you have one?

@codecov
Copy link

codecov bot commented May 1, 2017

Codecov Report

Merging #4620 into master will decrease coverage by 22.93%.
The diff coverage is 21.42%.

@@              Coverage Diff              @@
##             master    #4620       +/-   ##
=============================================
- Coverage     54.28%   31.34%   -22.94%     
- Complexity    22086    22090        +4     
=============================================
  Files          1360     1360               
  Lines         84659    84063      -596     
  Branches       1325     1325               
=============================================
- Hits          45958    26352    -19606     
- Misses        38701    57711    +19010
Impacted Files Coverage Δ Complexity Δ
lib/private/PreviewManager.php 0% <ø> (-3.85%) 49 <0> (ø)
...iles_trashbin/lib/Controller/PreviewController.php 67.56% <0%> (-3.87%) 9 <0> (+1)
...iles_versions/lib/Controller/PreviewController.php 56.66% <0%> (-4.05%) 8 <0> (+1)
core/Controller/PreviewController.php 63.63% <0%> (-3.04%) 12 <0> (+1)
...sharing/lib/Controller/PublicPreviewController.php 58.82% <0%> (-3.68%) 10 <0> (+1)
lib/private/legacy/image.php 38.17% <50%> (-0.89%) 212 <0> (ø)
lib/private/Preview/Generator.php 85.61% <50%> (-0.5%) 42 <0> (+1)
apps/files_sharing/lib/AppInfo/Application.php 0% <0%> (-100%) 3% <0%> (-1%)
apps/comments/lib/AppInfo/Application.php 0% <0%> (-100%) 1% <0%> (ø)
...ivate/Files/Cache/Wrapper/CachePermissionsMask.php 0% <0%> (-100%) 3% <0%> (ø)
... and 362 more

@MorrisJobke
Copy link
Member

I also added some error handling for the other endpoints that uses that method.

@@ -325,6 +327,10 @@ private function generatePreview(ISimpleFolder $previewFolder, ISimpleFile $maxP
$preview->resize(max($width, $height));
}

if (!$preview->valid()) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be moved up? Like right after the getImage call?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

icewind1991 and others added 4 commits May 2, 2017 13:43
Signed-off-by: Morris Jobke <[email protected]>
Signed-off-by: Morris Jobke <[email protected]>
Signed-off-by: Robin Appelman <[email protected]>
@icewind1991 icewind1991 force-pushed the preview-error-handling branch from bfb8588 to 2847e9f Compare May 2, 2017 11:44
@rullzer rullzer merged commit 24ff230 into master May 2, 2017
@rullzer rullzer deleted the preview-error-handling branch May 2, 2017 19:49
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants