utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddColumnIfNotExist

func AddColumnIfNotExist(db *sqlx.DB, tableName, columnName, columnType, defaultValue string, nullable bool) error

func BuildAssetPath

func BuildAssetPath(rootFolder, collectionPath, assetName, extension string) (string, error)

func BuildCollectionPath

func BuildCollectionPath(rootFolder, collectionPath string) (string, error)

func BytesToHumanReadable

func BytesToHumanReadable(bytes int) string

func CheckHashPassword

func CheckHashPassword(storedPassword string, password string) (bool, error)

func Contains

func Contains(slice []string, item string) bool

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst. If dst already exists, it will be overwritten.

func CreateSchema

func CreateSchema(db *sqlx.DB, schema string) error

func CreateSchemaTx

func CreateSchemaTx(tx *sqlx.Tx, schema string) error

func DeleteColumn

func DeleteColumn(db *sqlx.DB, tableName, columnName string) error

func DeleteColumnIfExists

func DeleteColumnIfExists(db *sqlx.DB, tableName, columnName string) error

func DirExists

func DirExists(dir string) bool

func EpochToRFC3339

func EpochToRFC3339(epoch int64) string

func ExpandPath

func ExpandPath(path string) (string, error)

func FileExists

func FileExists(filePath string) bool

func FormatDateTime

func FormatDateTime(t time.Time, timezone *time.Location, locale language.Tag) string

func GenerateToken

func GenerateToken() string

func GenerateXXHashChecksum

func GenerateXXHashChecksum(filePath string) (string, error)

func GetCollectionPaths

func GetCollectionPaths(collectionPath string) []string

func GetCurrentTime

func GetCurrentTime() string

func GetEnv

func GetEnv(key, fallback string) string

func GetEpochTime

func GetEpochTime() int64

func GetIsClosed

func GetIsClosed(tx *sqlx.Tx) (bool, error)

func GetLastSyncTime

func GetLastSyncTime(tx *sqlx.Tx) (int64, error)

func GetMD5Hash

func GetMD5Hash(text string) string

func GetParent

func GetParent(p string) string

func GetProjectFile

func GetProjectFile(tx *sqlx.Tx) (string, error)

func GetProjectFolder

func GetProjectFolder(tx *sqlx.Tx) (string, error)

func GetProjectIcon

func GetProjectIcon(tx *sqlx.Tx) (string, error)

func GetProjectId

func GetProjectId(tx *sqlx.Tx) (string, error)

func GetProjectName

func GetProjectName(tx *sqlx.Tx) (string, error)

func GetProjectSyncToken

func GetProjectSyncToken(tx *sqlx.Tx) (string, error)

func GetProjectVersion

func GetProjectVersion(tx *sqlx.Tx) (float64, error)

func GetProjectWorkingDir

func GetProjectWorkingDir(tx *sqlx.Tx) (string, error)

func GetRemoteUrl

func GetRemoteUrl(tx *sqlx.Tx) (string, error)

GetRemoteUrl reads the remote project URL from the config table.

func GetStudioName

func GetStudioName(tx *sqlx.Tx) (string, error)

func GetWriteThroughEnabled

func GetWriteThroughEnabled(tx *sqlx.Tx) (bool, error)

GetWriteThroughEnabled reads the write_through_enabled config value for a project. Returns false if the key is missing (default off).

func HashPassword

func HashPassword(password string) (string, error)

func IsColumnExist

func IsColumnExist(db *sqlx.DB, tableName, columnName string) (bool, error)

func IsProjectDirty

func IsProjectDirty(tx *sqlx.Tx) (bool, error)

func IsValidPointer

func IsValidPointer(pointer string) bool

func IsValidURL

func IsValidURL(link string) bool

IsValidURL checks if the input string is a valid URL

func LaunchFile

func LaunchFile(filePath string) error

func MatchesRegex

func MatchesRegex(path string, pattern string) (bool, error)

func NonCaseSensitiveContains

func NonCaseSensitiveContains(slice []string, item string) bool

func NormalizePath

func NormalizePath(path string) string

func OpenDb

func OpenDb(dbPath string) (*sqlx.DB, error)

func RFC3339ToEpoch

func RFC3339ToEpoch(rfc3339 string) (int64, error)

func RemoveDuplicates

func RemoveDuplicates(slice []string) []string

func RenameColumn

func RenameColumn(db *sqlx.DB, tableName, oldColumnName, newColumnName string) error

RenameColumn renames a column in the SQLite database.

func RenameTable

func RenameTable(db *sqlx.DB, oldName, newName string) error

func ResizeImage

func ResizeImage(fileBytes []byte, width, height uint) ([]byte, error)

ResizeImage resizes the image bytes to the specified width and height.

func RevealInExplorer

func RevealInExplorer(filePath string)

func SetIsClosed

func SetIsClosed(tx *sqlx.Tx, isClosed bool) error

func SetLastSyncTime

func SetLastSyncTime(tx *sqlx.Tx, lastSyncTime int64) error

func SetProjectDirty

func SetProjectDirty(tx *sqlx.Tx, isDirty bool) error

func SetProjectIcon

func SetProjectIcon(tx *sqlx.Tx, projectIcon string) error

func SetProjectIgnoreList

func SetProjectIgnoreList(tx *sqlx.Tx, ignoreList []string) error

func SetProjectSyncToken

func SetProjectSyncToken(tx *sqlx.Tx, syncToken string) error

func SetProjectVersion

func SetProjectVersion(tx *sqlx.Tx, version float64) error

func SetProjectWorkingDir

func SetProjectWorkingDir(tx *sqlx.Tx, workingDir string) error

func SetRemoteUrl

func SetRemoteUrl(tx *sqlx.Tx, remoteUrl string) error

SetRemoteUrl writes the remote project URL to the config table.

func SetRowsSynced

func SetRowsSynced(tx *sqlx.Tx, table string, ids []string) error

SetRowsSynced marks specific rows as synced in a given table by their IDs. This prevents race conditions where unrelated unsynced rows get marked.

func SetStudioName

func SetStudioName(tx *sqlx.Tx, studioName string) error

func SetTableToSynced

func SetTableToSynced(tx *sqlx.Tx, table string) error

func SetTablesToSynced

func SetTablesToSynced(tx *sqlx.Tx, tables []string) error

func SetWriteThroughEnabled

func SetWriteThroughEnabled(tx *sqlx.Tx, enabled bool) error

SetWriteThroughEnabled writes the write_through_enabled config value for a project.

func Slugify

func Slugify(text, separator string, lowercase bool) string

func SplitStatements

func SplitStatements(content string) []string

func StructToMap

func StructToMap(data interface{}, snake_case bool) map[string]interface{}

func TableExists

func TableExists(db *sqlx.DB, tableName string) (bool, error)

func ToSnakeCase

func ToSnakeCase(text string) string

func ValidateEmail

func ValidateEmail(email string) bool

func ValidatePassword

func ValidatePassword(password string) (bool, string)

Types

type ColumnInfo

type ColumnInfo struct {
	Cid       int            `db:"cid"`
	Name      string         `db:"name"`
	Type      string         `db:"type"`
	NotNull   int            `db:"notnull"`
	DfltValue sql.NullString `db:"dflt_value"`
	Pk        int            `db:"pk"`
}

ColumnInfo holds the schema information for a column

type ProjectContext

type ProjectContext struct {
	ProjectPath string
	DbConn      *sqlx.DB
	Tx          *sqlx.Tx
	UseTx       bool
}

Jump to

Keyboard shortcuts

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