sliproad/files/fileutils.go
Gabriel Simmer 207676d4a7
Correct config provider, no backblaze goroutine.
Addressing a bug where the configuration would try to interpret the
provider name from the entry in the configuration, rather than the
explicit `provider`. Also removed background uploading from Backblaze
(was worth a shot).
2020-04-02 15:31:30 +01:00

36 lines
849 B
Go

package files
import "fmt"
var ProviderConfig map[string]FileProvider
var Providers map[string]*FileProviderInterface
func TranslateProvider(codename string, i *FileProviderInterface) {
provider := ProviderConfig[codename]
if provider.Provider == "disk" {
*i = &DiskProvider{provider,}
return
}
if provider.Provider == "backblaze" {
bbProv := &BackblazeProvider{provider, provider.Config["bucket"], ""}
*i = bbProv
return
}
*i = FileProvider{}
}
func SetupProviders() {
Providers = make(map[string]*FileProviderInterface)
for name, provider := range ProviderConfig {
var i FileProviderInterface
TranslateProvider(name, &i)
success := i.Setup(provider.Config)
if !success {
fmt.Printf("%s failed to initialize\n", name)
} else {
Providers[name] = &i
fmt.Printf("%s initialized successfully\n", name)
}
}
}