db

package
v0.0.0-...-fa1d128 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package db manages the database of the app

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePasswordOfPath

func ChangePasswordOfPath(ctx context.Context, db *DB, path string, password string) error

func CheckIfPathHasAuth

func CheckIfPathHasAuth(ctx context.Context, db *DB, path string) (bool, error)

CheckIfPathHasAuth checks if a given path requires authentication to access.

func CreateAuthForPath

func CreateAuthForPath(ctx context.Context, db *DB, path string, password string) error

CreateAuthForPath inserts a new path with the given password into the database.

func GetPasswordOfPath

func GetPasswordOfPath(ctx context.Context, db *DB, path string) (string, error)

GetPasswordOfPath retrieves the password for a given path from the database.

func RemovePasswordOfPath

func RemovePasswordOfPath(ctx context.Context, db *DB, path string) error

func RemoveUploadSessionByPath

func RemoveUploadSessionByPath(ctx context.Context, db *DB, path string, filename string) error

RemoveUploadSessionByPath removes all upload sessions by their path and filename from the database.

func RemoveUploadSessionByToken

func RemoveUploadSessionByToken(ctx context.Context, db *DB, tokenString string) error

RemoveUploadSessionByToken removes an upload session by its token from the database.

func RenameAuthPath

func RenameAuthPath(ctx context.Context, db *DB, oldPath string, newPath string) error

func SaveUploadSession

func SaveUploadSession(ctx context.Context, db *DB, session map[string]any) error

SaveUploadSession saves an upload session into the database.

Types

type DB

type DB struct {
	*sqlx.DB
}

func New

func New(dbFilePath string) (*DB, error)

New creates a new database connection.

Params:

dbFilePath string // The path to the SQLite database file.

Returns:

*DB // The new database connection.
error // An error if any occurred during the database connection process.

func (*DB) GetVersion

func (db *DB) GetVersion(ctx context.Context) (version string, err error)

GetVersion retrieves the current version of the database.

Returns:

string // The current version of the database.
error // An error if any occurred during the version retrieval process.

type ItemPassword

type ItemPassword struct {
	ID       int64  `db:"id"`
	Path     string `db:"path"`
	Password string `db:"password"`
}

type UploadSession

type UploadSession struct {
	Token     string `db:"token"`
	Path      string `db:"path"`
	Filename  string `db:"filename"`
	CreatedAt int64  `db:"created_at"`
}

func GetUploadSession

func GetUploadSession(ctx context.Context, db *DB, tokenString string) (result *UploadSession, err error)

GetUploadSession retrieves an upload session by its token from the database. If no session is found, it returns nil and nil.

Jump to

Keyboard shortcuts

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