This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
bug: report error from image library #349
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4377d14
bug: report error from image library
jrconlin 27e1ed9
f cargo update to remove 2022-0006
jrconlin a3a1216
f correct iPad UA in integration tests
jrconlin a4bccb6
Merge branch 'main' of github.com:mozilla-services/contile into bug/3…
jrconlin e767a61
Merge branch 'main' of github.com:mozilla-services/contile into bug/3…
jrconlin 64a910b
f restore ipad test UA
jrconlin ac3e3b0
Merge branch 'main' of github.com:mozilla-services/contile into bug/3…
jrconlin d377754
f dbg
jrconlin 9c46428
f dbg
jrconlin 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 |
---|---|---|
|
@@ -187,12 +187,23 @@ impl StoreImage { | |
})) | ||
} | ||
|
||
pub fn meta(&self, image: &Bytes, fmt: ImageFormat) -> HandlerResult<ImageMetrics> { | ||
pub fn meta( | ||
&self, | ||
uri: &uri::Uri, | ||
image: &Bytes, | ||
fmt: ImageFormat, | ||
) -> HandlerResult<ImageMetrics> { | ||
let mut reader = ImageReader::new(Cursor::new(image)); | ||
reader.set_format(fmt); | ||
let img = reader | ||
.decode() | ||
.map_err(|_| HandlerErrorKind::BadImage("Image unreadable"))?; | ||
let img = reader.decode().map_err(|e| { | ||
let mut tags = Tags::default(); | ||
tags.add_extra("error", &e.to_string()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sigh. |
||
tags.add_extra("url", &uri.to_string()); | ||
tags.add_extra("format", fmt.extensions_str().first().unwrap_or(&"Unknown")); | ||
let mut err: HandlerError = HandlerErrorKind::BadImage("Image unreadable").into(); | ||
err.tags = tags; | ||
err | ||
})?; | ||
let rgb_img = img.to_rgb16(); | ||
Ok(ImageMetrics { | ||
height: rgb_img.height(), | ||
|
@@ -271,13 +282,14 @@ impl StoreImage { | |
_ => { | ||
let mut tags = Tags::default(); | ||
tags.add_extra("url", &uri.to_string()); | ||
tags.add_extra("format", content_type); | ||
let mut err: HandlerError = | ||
HandlerErrorKind::BadImage("Invalid image format").into(); | ||
err.tags = tags; | ||
return Err(err); | ||
} | ||
}; | ||
self.meta(image, fmt)? | ||
self.meta(uri, image, fmt)? | ||
}; | ||
if self.settings.metrics.symmetric && image_metrics.width != image_metrics.height { | ||
let mut tags = Tags::default(); | ||
|
This file contains 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 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
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.
forgot to kill this
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.
argh... hang on.