update

package
v0.0.0-...-6e294cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package update updates songs in datastore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPlay

func AddPlay(ctx context.Context, id int64, startTime time.Time, ip string) error

AddPlay adds a play report to the song identified by id in datastore.

func ClearData

func ClearData(ctx context.Context) error

ClearData deletes all song and play objects from datastore. It's intended for testing and can only be called on dev servers.

func DeleteSong

func DeleteSong(ctx context.Context, id int64) error

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL