From 59a506dea038f693414efed5f1edaa65a09a48e3 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Mon, 16 Oct 2017 16:52:55 -0700 Subject: error checking on exif handling --- post/post.go | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'post') diff --git a/post/post.go b/post/post.go index c43b9e3..8f96c8d 100644 --- a/post/post.go +++ b/post/post.go @@ -143,12 +143,27 @@ func (p *Post) AbsoluteFilePath() string { Try to extract metadata from EXIF */ func (p *Post) parseExif() { - // TODO: full exif parsing / metadata propogation - // TODO: error checking - f, _ := os.Open(p.AbsoluteFilePath()) - x, _ := exif.Decode(f) - tm, _ := x.DateTime() + f, err := os.Open(p.AbsoluteFilePath()) + if err != nil { + vlog.Printf("%v", err) + return + } + + x, err := exif.Decode(f) + if err != nil { + vlog.Printf("%v", err) + return + } + + tm, err := x.DateTime() + if err != nil { + vlog.Printf("%v", err) + return + } p.Time = tm + + // TODO: full exif parsing | metadata propogation but exif is ugh + p.Meta["Exif"] = x.String() } /* @@ -203,6 +218,10 @@ func NormalizeTag(tag string) string { splitText splits up p.Unparsed into p.Text and p.Meta[attr][value] */ func (p *Post) splitTextMeta() { + if p.Unparsed == "" { + p.Text = "" + return + } SEPARATOR := ":" lines := strings.Split(p.Unparsed, "\n") for _, line := range lines { -- cgit v1.2.3