mirror of https://github.com/perkeep/perkeep.git
images: double-check djpeg's failure with process state, to avoid false
alarm http://camlistore.org/issue/550 Also fix confusing error msg Change-Id: I68dd3c5a11f5b32028d21c006d73c55da950a58c
This commit is contained in:
parent
21a61dad40
commit
009e63ea77
|
@ -196,9 +196,12 @@ func DecodeDownsample(r io.Reader, factor int) (image.Image, error) {
|
|||
|
||||
stderrW := new(bytes.Buffer)
|
||||
cmd.Stderr = stderrW
|
||||
if err = cmd.Run(); err != nil {
|
||||
djpegFailureVar.Add(1)
|
||||
return nil, DjpegFailedError{Err: fmt.Errorf("%v: %s", err, stderrW)}
|
||||
if err := cmd.Run(); err != nil {
|
||||
if !cmd.ProcessState.Success() {
|
||||
djpegFailureVar.Add(1)
|
||||
return nil, DjpegFailedError{Err: fmt.Errorf("%v: %s", err, stderrW)}
|
||||
}
|
||||
// false alarm, so proceed. See http://camlistore.org/issue/550
|
||||
}
|
||||
djpegSuccessVar.Add(1)
|
||||
djpegBytesReadVar.Add(int64(w.Len()))
|
||||
|
|
|
@ -432,7 +432,7 @@ func decode(r io.Reader, opts *DecodeOpts, swapDimensions bool) (im image.Image,
|
|||
im, err = fastjpeg.DecodeDownsample(tr, factor)
|
||||
switch err.(type) {
|
||||
case fastjpeg.DjpegFailedError:
|
||||
log.Printf("djpeg failed, retrying with jpeg.Decode: %v", err)
|
||||
log.Printf("Retrying with jpeg.Decode, because djpeg failed with: %v", err)
|
||||
im, err = jpeg.Decode(io.MultiReader(&buf, mr))
|
||||
case nil:
|
||||
// fallthrough to rescale() below.
|
||||
|
|
Loading…
Reference in New Issue