Documentation
¶
Overview ¶
Package gallerylib provides the business logic for importing and managing gallery content in the database.
Index ¶
- type Importer
- func (imp *Importer) CreateRootFolderEntry(ctx context.Context, mtime int64) (int64, error)
- func (imp *Importer) UpdateFolderTileChain(ctx context.Context, folderID, tileFileID int64) error
- func (imp *Importer) UpsertPathChain(ctx context.Context, path string, mtime, size int64, md5 string, ...) (gallerydb.File, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Importer ¶
type Importer struct {
Conn *sql.Conn
Q *gallerydb.CustomQueries
}
Importer provides methods for adding gallery content to the database.
func (*Importer) CreateRootFolderEntry ¶
CreateRootFolderEntry creates or retrieves the root folder record in the database. It is idempotent and safe for concurrent calls. mtime is the filesystem modification time of the root directory (unix seconds). It returns the ID of the root folder.
func (*Importer) UpdateFolderTileChain ¶
UpdateFolderTileChain updates the tile_id for a given folder and recursively ascends the folder hierarchy. It sets the `tile_id` for each parent folder to the provided `tileFileID` until it reaches a folder that already has a tile or it reaches the root of the gallery. The `tileFileID` parameter must be an ID from the `files` table.
func (*Importer) UpsertPathChain ¶
func (imp *Importer) UpsertPathChain(ctx context.Context, path string, mtime, size int64, md5 string, phash, width, height int64, mimeType string) (gallerydb.File, error)
UpsertPathChain ensures that all intermediate folders and the file record exist. It returns the final file record.