utils

package
v0.0.0-...-3951416 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DiskUsageCache     = cache.NewCache[bool](30*time.Second, 24*time.Hour)
	RealPathCache      = cache.NewCache[string](48*time.Hour, 72*time.Hour)
	SearchResultsCache = cache.NewCache[string](15*time.Second, 1*time.Hour)
	OnlyOfficeCache    = cache.NewCache[string](48*time.Hour, 1*time.Hour)
	JwtCache           = cache.NewCache[string](1*time.Hour, 72*time.Hour)
)

Functions

func CapitalizeFirst

func CapitalizeFirst(s string) string

CapitalizeFirst returns the input string with the first letter capitalized.

func CheckErr

func CheckErr(source string, err error)

func CheckForUpdates

func CheckForUpdates() (updateInfo, error)

func GenerateKey

func GenerateKey() string

func GenerateRandomPath

func GenerateRandomPath(levels int) string

func GenerateRandomSearchTerms

func GenerateRandomSearchTerms(numTerms int) []string

func GetChecksum

func GetChecksum(fullPath, algo string) (string, error)

GetChecksum calculates the checksum of a file using the specified algorithm. Returns the checksum as a hex-encoded string.

func GetLastComponent

func GetLastComponent(path string) string

func GetParentDirectoryPath

func GetParentDirectoryPath(path string) string

func GetRandomExtension

func GetRandomExtension() string

func GetRandomTerm

func GetRandomTerm() string

func GetUpdateAvailableUrl

func GetUpdateAvailableUrl() string

func HashSHA256

func HashSHA256(data string) string

func InsecureRandomIdentifier

func InsecureRandomIdentifier(length int) string

func JoinPathAsUnix

func JoinPathAsUnix(parts ...string) string

func NonNilSlice

func NonNilSlice[T any](in []T) []T

func PrintStructFields

func PrintStructFields(v interface{})

func StartCheckForUpdates

func StartCheckForUpdates()

starts a background process to check for updates periodically.

func Ternary

func Ternary[T any](cond bool, vtrue, vfalse T) T

Types

type FileOptions

type FileOptions struct {
	Username                 string // username for access control
	Path                     string // realpath
	Source                   string
	IsDir                    bool
	Modify                   bool
	Expand                   bool
	ReadHeader               bool
	Content                  bool
	Recursive                bool // whether to recursively index directories
	Metadata                 bool // whether to get metadata
	ExtractEmbeddedSubtitles bool // whether to extract embedded subtitles from media files
}

FileOptions are the options when getting a file info.

type Tag

type Tag struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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