"Remove from library" deletes the audio_files row and records the path as excluded, so the next scan does not import it again. Without the exclusion the operation undoes itself on the next scan, which is worse than not having it at all; the file on disk is never touched, which is the promise the confirmation copy will make. The soft scan compares the number of audio files on disk against the number of rows, so both walks now skip excluded paths — otherwise the two counts disagree forever and every launch queues a full scan of the whole library. A full rescan clears the exclusions, which is the only way back for a path removed by mistake until there is a UI for it.
76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: excluded_paths.sql
|
|
|
|
package sqlcgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const clearExcludedPaths = `-- name: ClearExcludedPaths :exec
|
|
DELETE FROM excluded_paths
|
|
`
|
|
|
|
func (q *Queries) ClearExcludedPaths(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, clearExcludedPaths)
|
|
return err
|
|
}
|
|
|
|
const countExcludedPathsByLibrary = `-- name: CountExcludedPathsByLibrary :one
|
|
SELECT COUNT(*) FROM excluded_paths
|
|
WHERE library_id = ?
|
|
`
|
|
|
|
func (q *Queries) CountExcludedPathsByLibrary(ctx context.Context, libraryID int64) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countExcludedPathsByLibrary, libraryID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const excludePath = `-- name: ExcludePath :exec
|
|
INSERT INTO excluded_paths (library_id, file_path)
|
|
VALUES (?, ?)
|
|
ON CONFLICT(library_id, file_path) DO NOTHING
|
|
`
|
|
|
|
type ExcludePathParams struct {
|
|
LibraryID int64
|
|
FilePath string
|
|
}
|
|
|
|
func (q *Queries) ExcludePath(ctx context.Context, arg ExcludePathParams) error {
|
|
_, err := q.db.ExecContext(ctx, excludePath, arg.LibraryID, arg.FilePath)
|
|
return err
|
|
}
|
|
|
|
const getExcludedPathsByLibrary = `-- name: GetExcludedPathsByLibrary :many
|
|
SELECT file_path FROM excluded_paths
|
|
WHERE library_id = ?
|
|
`
|
|
|
|
func (q *Queries) GetExcludedPathsByLibrary(ctx context.Context, libraryID int64) ([]string, error) {
|
|
rows, err := q.db.QueryContext(ctx, getExcludedPathsByLibrary, libraryID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []string
|
|
for rows.Next() {
|
|
var file_path string
|
|
if err := rows.Scan(&file_path); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, file_path)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|