pull/211/head
Henrique Dias 2017-08-20 10:09:10 +01:00
parent 82b161cfb2
commit 4bf34124a3
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
1 changed files with 10 additions and 1 deletions

View File

@ -20,6 +20,8 @@ import (
"github.com/spf13/viper"
)
var databases = map[string]*storm.DB{}
// Parse ...
func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, error) {
var (
@ -190,7 +192,14 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
u.Scope = scope
u.FileSystem = fileutils.Dir(scope)
db, err := storm.Open(database)
var db *storm.DB
if stored, ok := databases[database]; ok {
db = stored
} else {
db, err = storm.Open(database)
databases[database] = db
}
if err != nil {
return nil, err
}