From dd710e69b69f82448eafba22dc5e4bb7f7b57f6c Mon Sep 17 00:00:00 2001 From: James Mills Date: Sun, 22 Mar 2020 18:18:59 +1000 Subject: Fixed nil refernece bug --- app/app.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/app.go') diff --git a/app/app.go b/app/app.go index 5d44884..475c99b 100644 --- a/app/app.go +++ b/app/app.go @@ -11,6 +11,7 @@ import ( "os" "path" "path/filepath" + "sort" "strings" rice "github.com/GeertJohan/go.rice" @@ -166,7 +167,14 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) { defer file.Close() // TODO: Make collection user selectable from drop-down in Form - collection := "videos" + // XXX: Assume we can put uploaded videos into the first collection (sorted) we find + keys := make([]string, 0, len(a.Library.Paths)) + for k := range a.Library.Paths { + keys = append(keys, k) + } + sort.Strings(keys) + collection := keys[0] + fn := filepath.Join( a.Config.Server.UploadPath, fmt.Sprintf( -- cgit v1.2.3