vendor: update thumbnail from 1.0.0 -> master

This commit is contained in:
mappu 2018-06-09 18:09:49 +12:00
parent dba699524f
commit be864235cb
6 changed files with 21 additions and 4 deletions

6
Gopkg.lock generated
View File

@ -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

View File

@ -23,7 +23,7 @@
[[constraint]]
name = "code.ivysaur.me/thumbnail"
version = "1.0.0"
branch = "master"
[[constraint]]
name = "github.com/boltdb/bolt"

View File

@ -4,3 +4,4 @@ efd7b407177086c57e8c086605c2c8d1cee23840 v0.1.0
efd7b407177086c57e8c086605c2c8d1cee23840 release-1.0
0000000000000000000000000000000000000000 release-1.0
2052254b2599ab6aa6a8de17a61f94646e2a62ef v0.2.1
8bfdf42aed323040992283e158fb4399baaeda2a v1.0.0

View File

@ -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

View File

@ -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

View File

@ -12,6 +12,7 @@ var (
type Thumbnailer interface {
RenderFile(absPath string) ([]byte, error)
RenderFileAs(absPath, mimeType string) ([]byte, error)
}
func FiletypeSupported(ext string) bool {