cli: Update to new DataStore interfaces

This commit is contained in:
Marius 2019-09-10 10:23:39 +02:00
parent d36b0ea3a9
commit e591c9ea69
2 changed files with 6 additions and 6 deletions

View File

@ -5,7 +5,6 @@ import (
"path/filepath"
"github.com/tus/tusd/pkg/filestore"
"github.com/tus/tusd/pkg/gcsstore"
"github.com/tus/tusd/pkg/handler"
"github.com/tus/tusd/pkg/memorylocker"
"github.com/tus/tusd/pkg/s3store"
@ -48,7 +47,7 @@ func CreateComposer() {
stderr.Fatalf("No service account file provided for Google Cloud Storage using the GCS_SERVICE_ACCOUNT_FILE environment variable.\n")
}
service, err := gcsstore.NewGCSService(gcsSAF)
/*service, err := gcsstore.NewGCSService(gcsSAF)
if err != nil {
stderr.Fatalf("Unable to create Google Cloud Storage service: %s\n", err)
}
@ -60,7 +59,7 @@ func CreateComposer() {
store.UseIn(Composer)
locker := memorylocker.New()
locker.UseIn(Composer)
locker.UseIn(Composer)*/
} else {
dir, err := filepath.Abs(Flags.UploadDir)
if err != nil {
@ -74,6 +73,7 @@ func CreateComposer() {
store := filestore.New(dir)
store.UseIn(Composer)
// TODO: Add locker
}
stdout.Printf("Using %.2fMB as maximum size.\n", float64(Flags.MaxSize)/1024/1024)

View File

@ -23,16 +23,16 @@ type hookDataStore struct {
handler.DataStore
}
func (store hookDataStore) NewUpload(info handler.FileInfo) (id string, err error) {
func (store hookDataStore) NewUpload(info handler.FileInfo) (handler.Upload, error) {
if output, err := invokeHookSync(hooks.HookPreCreate, info, true); err != nil {
if hookErr, ok := err.(hooks.HookError); ok {
return "", hooks.NewHookError(
return nil, hooks.NewHookError(
fmt.Errorf("pre-create hook failed: %s", err),
hookErr.StatusCode(),
hookErr.Body(),
)
}
return "", fmt.Errorf("pre-create hook failed: %s\n%s", err, string(output))
return nil, fmt.Errorf("pre-create hook failed: %s\n%s", err, string(output))
}
return store.DataStore.NewUpload(info)
}