From be864235cb33dfbbfaf57ecbc97d9cbc3d3b1535 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 9 Jun 2018 18:09:49 +1200 Subject: [PATCH] vendor: update thumbnail from 1.0.0 -> master --- Gopkg.lock | 6 +++--- Gopkg.toml | 2 +- vendor/code.ivysaur.me/thumbnail/.hgtags | 1 + vendor/code.ivysaur.me/thumbnail/CachingThumbnailer.go | 9 +++++++++ vendor/code.ivysaur.me/thumbnail/DirectThumbnailer.go | 6 ++++++ vendor/code.ivysaur.me/thumbnail/Thumbnailer.go | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 8f37966..ef821dd 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -8,10 +8,10 @@ revision = "6a468707fb1bb44c4bb71113273cc73daf401976" [[projects]] + branch = "master" name = "code.ivysaur.me/thumbnail" packages = ["."] - revision = "ebd644298ee641e21ff72e3f14f09b3b061f7cd8" - version = "v1.0.0" + revision = "13e0990a33026cba5f746c13c85782e562e61fa6" [[projects]] name = "github.com/boltdb/bolt" @@ -52,6 +52,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "6d4cc842003fa8fe59eb9d1e21cc10fbff49715a541e93764f5190a39344f989" + inputs-digest = "907370ab34b6a574b2845b17f9033acb75dfc5c8348266167f95f0112f38e89a" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 8c50f10..cbb11cf 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -23,7 +23,7 @@ [[constraint]] name = "code.ivysaur.me/thumbnail" - version = "1.0.0" + branch = "master" [[constraint]] name = "github.com/boltdb/bolt" diff --git a/vendor/code.ivysaur.me/thumbnail/.hgtags b/vendor/code.ivysaur.me/thumbnail/.hgtags index 60b17eb..3b18392 100644 --- a/vendor/code.ivysaur.me/thumbnail/.hgtags +++ b/vendor/code.ivysaur.me/thumbnail/.hgtags @@ -4,3 +4,4 @@ efd7b407177086c57e8c086605c2c8d1cee23840 v0.1.0 efd7b407177086c57e8c086605c2c8d1cee23840 release-1.0 0000000000000000000000000000000000000000 release-1.0 2052254b2599ab6aa6a8de17a61f94646e2a62ef v0.2.1 +8bfdf42aed323040992283e158fb4399baaeda2a v1.0.0 diff --git a/vendor/code.ivysaur.me/thumbnail/CachingThumbnailer.go b/vendor/code.ivysaur.me/thumbnail/CachingThumbnailer.go index 390408f..fa508b9 100644 --- a/vendor/code.ivysaur.me/thumbnail/CachingThumbnailer.go +++ b/vendor/code.ivysaur.me/thumbnail/CachingThumbnailer.go @@ -1,6 +1,9 @@ package thumbnail import ( + "mime" + "path/filepath" + lru "github.com/hashicorp/golang-lru" ) @@ -9,6 +12,8 @@ type CachingThumbnailer struct { cache *lru.Cache // threadsafe, might be nil } +var _ Thumbnailer = &CachingThumbnailer{} // interface assertion + func NewCachingThumbnailer(cacheSize int, opts *Config) (Thumbnailer, error) { upstream := NewThumbnailerEx(opts) @@ -29,7 +34,11 @@ func NewCachingThumbnailer(cacheSize int, opts *Config) (Thumbnailer, error) { } func (this *CachingThumbnailer) RenderFile(absPath string) ([]byte, error) { + mimeType := mime.TypeByExtension(filepath.Ext(absPath)) + return this.RenderFileAs(absPath, mimeType) +} +func (this *CachingThumbnailer) RenderFileAs(absPath, mimeType string) ([]byte, error) { thumb, ok := this.cache.Get(absPath) if ok { return thumb.([]byte), nil diff --git a/vendor/code.ivysaur.me/thumbnail/DirectThumbnailer.go b/vendor/code.ivysaur.me/thumbnail/DirectThumbnailer.go index e78cd3a..864d840 100644 --- a/vendor/code.ivysaur.me/thumbnail/DirectThumbnailer.go +++ b/vendor/code.ivysaur.me/thumbnail/DirectThumbnailer.go @@ -11,6 +11,8 @@ type DirectThumbnailer struct { cfg Config } +var _ Thumbnailer = &DirectThumbnailer{} // interface assertion + func NewThumbnailer(w, h int) Thumbnailer { opts := DefaultConfig opts.Width = w @@ -29,6 +31,10 @@ func NewThumbnailerEx(opts *Config) Thumbnailer { func (this *DirectThumbnailer) RenderFile(absPath string) ([]byte, error) { mimeType := mime.TypeByExtension(filepath.Ext(absPath)) + return this.RenderFileAs(absPath, mimeType) +} + +func (this *DirectThumbnailer) RenderFileAs(absPath, mimeType string) ([]byte, error) { // Decode source diff --git a/vendor/code.ivysaur.me/thumbnail/Thumbnailer.go b/vendor/code.ivysaur.me/thumbnail/Thumbnailer.go index 0643023..c04bfc6 100644 --- a/vendor/code.ivysaur.me/thumbnail/Thumbnailer.go +++ b/vendor/code.ivysaur.me/thumbnail/Thumbnailer.go @@ -12,6 +12,7 @@ var ( type Thumbnailer interface { RenderFile(absPath string) ([]byte, error) + RenderFileAs(absPath, mimeType string) ([]byte, error) } func FiletypeSupported(ext string) bool {