Can upload new track
This commit is contained in:
parent
0a3b403d10
commit
192ff6c4e1
4 changed files with 114 additions and 4 deletions
|
|
@ -18,6 +18,16 @@ type Track struct {
|
|||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
func LoadTrack(path string, d fs.FileInfo) (track *Track, err error) {
|
||||
hash := sha512.Sum512([]byte(path))
|
||||
return &Track{
|
||||
Id: hash[:],
|
||||
Name: strings.TrimSuffix(d.Name(), filepath.Ext(d.Name())),
|
||||
Path: path,
|
||||
Enabled: len(strings.Split(path, "/")) == 2,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func LoadTracks(cfg *config.Config) (tracks []*Track, err error) {
|
||||
err = filepath.Walk(cfg.TracksDir, func(path string, d fs.FileInfo, err error) error {
|
||||
if d.Mode().IsRegular() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue