Newer
Older
//
// tank
//
// Import and Playlist Daemon for autoradio project
//
//
// Copyright (C) 2017 Christian Pointner <equinox@helsinki.at>
//
// This file is part of tank.
//
// tank is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// tank is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with tank. If not, see <http://www.gnu.org/licenses/>.
//
package store
import (
func getFileBucket(tx *bolt.Tx, group string) (files *bolt.Bucket, err error) {
var gb *bolt.Bucket
if gb, err = getGroupBucket(tx, group); err != nil {
return
}
if gb == nil {
return nil, nil
}
files = gb.Bucket([]byte(filesBn))
return
func (st *Store) ListFiles(group string) (files Files, err error) {
err = st.db.View(func(tx *bolt.Tx) error {
fb, err := getFileBucket(tx, group)
if err != nil {
return err
}
if fb != nil {
return nil
}
err = fb.ForEach(func(k, v []byte) error {
var file File
if err := json.Unmarshal(v, file); err != nil {
return err
}
files = append(files, file)
return nil
})
return err
})
return
}
func (st *Store) CreateFile(group, id string, file *File) error {
}
func (st *Store) GetFile(group, id string) (*File, error) {
// TODO: implement this
return nil, ErrNotImplented
}
func (st *Store) UpdateFile(group, id string, new File) (*File, error) {
// TODO: implement this
return nil, ErrNotImplented
}
func (st *Store) DeleteFile(group, id string) error {
// TODO: implement this
return ErrNotImplented
}