fix: issues
This commit is contained in:
@@ -27,3 +27,11 @@ func GetSubDirs(root string) ([]string, error) {
|
||||
|
||||
return paths, nil
|
||||
}
|
||||
|
||||
func DirExists(path string) bool {
|
||||
st, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return st.IsDir()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// swagger:enum MediaType
|
||||
@@ -14,12 +16,9 @@ import (
|
||||
// )
|
||||
type MediaType string
|
||||
|
||||
type MediaSource struct {
|
||||
Duration int64 `json:"duration"`
|
||||
Items []MediaSourceItem `json:"items"`
|
||||
}
|
||||
type MediaResources []MediaType
|
||||
|
||||
func (x MediaSource) Scan(value interface{}) (err error) {
|
||||
func (x MediaResources) Scan(value interface{}) (err error) {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
return json.Unmarshal([]byte(v), &x)
|
||||
@@ -31,12 +30,10 @@ func (x MediaSource) Scan(value interface{}) (err error) {
|
||||
return errors.New("Unknown type for ")
|
||||
}
|
||||
|
||||
func (x MediaSource) Value() (driver.Value, error) {
|
||||
func (x MediaResources) Value() (driver.Value, error) {
|
||||
return json.Marshal(x)
|
||||
}
|
||||
|
||||
type MediaSourceItem struct {
|
||||
Source string `json:"source"`
|
||||
Size int64 `json:"size"`
|
||||
Duration int64 `json:"duration"`
|
||||
func (x MediaResources) MustValue() driver.Value {
|
||||
return lo.Must(json.Marshal(x))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user