mirror of
https://github.com/gmemstr/sliproad.git
synced 2024-09-19 16:11:11 +01:00
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).
This commit is contained in:
parent
58128a0e98
commit
207676d4a7
|
@ -214,13 +214,16 @@ func (bp *BackblazeProvider) SaveFile(file multipart.File, handler *multipart.Fi
|
|||
}
|
||||
|
||||
var data BackblazeUploadInfo
|
||||
json.Unmarshal(bucketData, &data)
|
||||
err = json.Unmarshal(bucketData, &data)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
req, err = http.NewRequest("POST",
|
||||
data.UploadUrl,
|
||||
file,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return false
|
||||
|
@ -243,12 +246,11 @@ func (bp *BackblazeProvider) SaveFile(file multipart.File, handler *multipart.Fi
|
|||
req.ContentLength = handler.Size
|
||||
|
||||
// Upload in background.
|
||||
go func() {
|
||||
res, err = client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}()
|
||||
res, err = client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -63,7 +63,11 @@ func (dp *DiskProvider) SaveFile(file multipart.File, handler *multipart.FileHea
|
|||
}
|
||||
defer f.Close()
|
||||
|
||||
io.Copy(f, file)
|
||||
_, err = io.Copy(f, file)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ var Providers map[string]*FileProviderInterface
|
|||
|
||||
func TranslateProvider(codename string, i *FileProviderInterface) {
|
||||
provider := ProviderConfig[codename]
|
||||
if codename == "disk" {
|
||||
if provider.Provider == "disk" {
|
||||
*i = &DiskProvider{provider,}
|
||||
return
|
||||
}
|
||||
|
||||
if codename == "backblaze" {
|
||||
if provider.Provider == "backblaze" {
|
||||
bbProv := &BackblazeProvider{provider, provider.Config["bucket"], ""}
|
||||
*i = bbProv
|
||||
return
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
)
|
||||
|
||||
func HandleProvider() common.Handler {
|
||||
|
||||
return func(rc *common.RouterContext, w http.ResponseWriter, r *http.Request) *common.HTTPError {
|
||||
vars := mux.Vars(r)
|
||||
if r.Method == "GET" {
|
||||
|
@ -66,7 +65,6 @@ func HandleProvider() common.Handler {
|
|||
}
|
||||
|
||||
func ListProviders() common.Handler {
|
||||
|
||||
return func(rc *common.RouterContext, w http.ResponseWriter, r *http.Request) *common.HTTPError {
|
||||
var providers []string
|
||||
for v, _ := range files.ProviderConfig {
|
||||
|
|
Loading…
Reference in a new issue