Documentation
¶
Overview ¶
Package update updates songs in datastore.
Index ¶
- func AddPlay(ctx context.Context, id int64, startTime time.Time, ip string) error
- func ClearData(ctx context.Context) error
- func DeleteSong(ctx context.Context, id int64) error
- func ReindexSongs(ctx context.Context, cursor string) (nextCursor string, scanned, updated int, err error)
- func SetRatingAndTags(ctx context.Context, id int64, rating *int, ...) (*common.Song, error)
- func UpdateOrInsertSong(ctx context.Context, updated *common.Song, dataPolicy UserDataPolicy, ...) (existingFilename string, err error)
- type UpdateKeyType
- type UserDataPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearData ¶
ClearData deletes all song and play objects from datastore. It's intended for testing and can only be called on dev servers.
func DeleteSong ¶
DeleteSong deletes the song identified by id from datastore.
func ReindexSongs ¶
func ReindexSongs(ctx context.Context, cursor string) (nextCursor string, scanned, updated int, err error)
ReindexSongs regenerates various fields for all songs in the database and updates songs that were changed. If nextCursor is non-empty, ReindexSongs should be called again to continue reindexing.
func SetRatingAndTags ¶
func SetRatingAndTags(ctx context.Context, id int64, rating *int, allTags, addTags, removeTags []string, delay time.Duration) (*common.Song, error)
SetRatingAndTags updates the rating and tags of the song identified by id in datastore. The rating is only updated if non-nil, and tags are not updated if allTags, addTags, and removeTags are all nil. If delay is nonzero, the server will wait before writing to datastore. The updated song is returned.
func UpdateOrInsertSong ¶
func UpdateOrInsertSong(ctx context.Context, updated *common.Song, dataPolicy UserDataPolicy, keyType UpdateKeyType, delay time.Duration) ( existingFilename string, err error)
UpdateOrInsertSong stores the supplied song in datastore. If delay is nonzero, the server will wait before writing to datastore. If the song (as identified by its SHA1) already exists in the database, its original Filename field is returned.
Types ¶
type UpdateKeyType ¶
type UpdateKeyType int
UpdateKeyType indicates the key that UpdateOrInsertSong should use to determine which song to update.
const ( // UpdateBySHA1 indicates that the Song.SHA1 field should be used. // This identifies songs by their audio data, so they will be tracked across renames or moves. UpdateBySHA1 UpdateKeyType = iota // UpdateByFilename indicates that the Song.Filename field should be used. // This is useful when a file's audio data has been deliberately updated. UpdateByFilename )
type UserDataPolicy ¶
type UserDataPolicy int
UserDataPolicy indicates what UpdateOrInsertSong should do with existing user data (e.g. ratings, tags, plays) when updating a song.
const ( // PreserveUserData indicates that the current user data should not be changed. PreserveUserData UserDataPolicy = iota // ReplaceUserData indicates that user data should be replaced by data from the imported song. ReplaceUserData )