mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-26 08:29:41 -05:00
542 lines
38 KiB
Go
542 lines
38 KiB
Go
package settings
|
|
|
|
import (
|
|
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
|
|
)
|
|
|
|
type AllowedMethods string
|
|
|
|
var Env Environment
|
|
|
|
const (
|
|
ProxyAuth AllowedMethods = "proxyAuth"
|
|
NoAuth AllowedMethods = "noAuth"
|
|
PasswordAuth AllowedMethods = "passwordAuth"
|
|
)
|
|
|
|
type Settings struct {
|
|
Server Server `json:"server"`
|
|
Auth Auth `json:"auth"`
|
|
Frontend Frontend `json:"frontend"`
|
|
UserDefaults UserDefaults `json:"userDefaults"` // optional signup/CLI defaults; per-user values are managed in the UI
|
|
ShareDefaults ShareDefaults `json:"shareDefaults"` // optional defaults for new shares; managed in the UI
|
|
Integrations Integrations `json:"integrations"`
|
|
Http Http `json:"http"`
|
|
}
|
|
|
|
type Http struct {
|
|
Socket string `json:"socket"` // socket to listen on - eg. /var/run/filebrowser.sock
|
|
TLSKey string `json:"tlsKey"` // path to TLS key
|
|
TLSCert string `json:"tlsCert"` // path to TLS cert
|
|
Port int `json:"port"` // port to listen on
|
|
ListenAddress string `json:"listen"` // address to listen on (default: 0.0.0.0)
|
|
BaseURL string `json:"baseURL"` // base URL for the server, the subpath that the server is running on.
|
|
ExternalUrl string `json:"externalUrl"` // used by share links if set (eg. http://mydomain.com)
|
|
InternalUrl string `json:"internalUrl"` // used by integrations if set, this is the base domain that an integration service will use to communicate with filebrowser (eg. http://localhost:8080)
|
|
DisableWebDAV bool `json:"disableWebDAV"` // disable webdav support (default: false)
|
|
TrustProxyHeaders bool `json:"trustProxyHeaders"` // honor X-Forwarded-* and X-Real-IP from a reverse proxy (default: false)
|
|
TrustedProxies []string `json:"trustedProxies"` // IPs/CIDRs of trusted proxies; forwarded client headers are only honored when the socket peer matches one of these (default: empty = forwarded headers ignored)
|
|
// UnixSocketTrustedUIDs and UnixSocketTrustedGIDs list peer credentials (Linux SO_PEERCRED) allowed to
|
|
// present X-Forwarded-* on a filesystem http.socket listener. When both are empty, forwarded headers
|
|
// are not trusted on Unix sockets. Abstract sockets (@name) never trust forwarded headers.
|
|
UnixSocketTrustedUIDs []int `json:"unixSocketTrustedUIDs"`
|
|
UnixSocketTrustedGIDs []int `json:"unixSocketTrustedGIDs"`
|
|
SocketFileMode string `json:"socketFileMode"` // octal mode for filesystem http.socket (default "0660"); ignored for abstract sockets
|
|
SocketGroup string `json:"socketGroup"` // optional group name or numeric gid for the socket file (filesystem sockets only)
|
|
DisableRateLimit bool `json:"disableRateLimit"` // turns off built-in auth route rate limiting and failed-login lockout (default false).
|
|
}
|
|
|
|
type Environment struct {
|
|
IsCLIMode bool `json:"-"` // true when running a CLI subcommand (user set, promote, etc.)
|
|
IsPlaywright bool `json:"-"`
|
|
IsDevMode bool `json:"-"`
|
|
IsFirstLoad bool `json:"-"` // used internally to track if this is the first load of the application
|
|
ConfigUserDefaultsSpecified bool `json:"-"` // true when the config file contained a userDefaults section
|
|
ConfigUserDefaultsSpecifiedPaths []string `json:"-"` // dot-paths explicitly set under userDefaults in config
|
|
ConfigMediaSpecifiedPaths []string `json:"-"` // dot-paths explicitly set under integrations.media in config
|
|
// ConfigSourceDefaultPermissions maps permission flags explicitly set in config defaultPermissions (e.g. view -> true).
|
|
ConfigSourceDefaultPermissions map[string]bool `json:"-"`
|
|
EmbeddedFs bool `json:"-"` // used internally if compiled with embedded fs support
|
|
FFmpegPath string `json:"-"`
|
|
FFprobePath string `json:"-"`
|
|
FFmpegAvailable bool `json:"-"`
|
|
HardwareAccelerationAvailable bool `json:"-"` // true when ffmpeg reports at least one usable hardware encoder
|
|
LoginIconPath string `json:"-"` // resolved login icon path (filesystem or embedded)
|
|
LoginIconIsCustom bool `json:"-"` // true if login icon is from custom filesystem path
|
|
LoginIconEmbeddedPath string `json:"-"` // embedded asset path for default icon
|
|
FaviconPath string `json:"-"` // resolved favicon path (filesystem or embedded)
|
|
FaviconIsCustom bool `json:"-"` // true if favicon is from custom filesystem path
|
|
FaviconEmbeddedPath string `json:"-"` // embedded asset path for default favicon
|
|
}
|
|
|
|
type Server struct {
|
|
SearchResultsLimit int `json:"searchResultsLimit" yaml:"searchResultsLimit" validate:"gte=1"` // maximum requested search results across all sources (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200
|
|
MinSearchLength int `json:"minSearchLength" yaml:"minSearchLength"` // minimum length of search query to begin searching (default: 3)
|
|
DisableUpdateCheck bool `json:"disableUpdateCheck"` // disables backend update check service
|
|
NumImageProcessors int `json:"numImageProcessors"` // number of concurrent image processing jobs used to create previews, default is 4.
|
|
DisablePreviews bool `json:"disablePreviews"` // disable all previews thumbnails, simple icons will be used
|
|
DisableResize bool `json:"disablePreviewResize"` // disable resizing of previews for faster loading over slow connections
|
|
DisableTypeDetectionByHeader bool `json:"disableTypeDetectionByHeader"` // disable type detection by header, useful if filesystem is slow.
|
|
Logging []LogConfig `json:"logging" yaml:"logging"`
|
|
Sources []*Source `json:"sources" validate:"required,dive"`
|
|
CacheDir string `json:"cacheDir"` // path to the cache directory, used for thumbnails and other cached files
|
|
CacheDirCleanup bool `json:"cacheDirCleanup"` // whether to automatically cleanup the cache directory. Note: docker must also mount a persistent volume to persist the cache (default: false)
|
|
MaxArchiveSizeGB int64 `json:"maxArchiveSize"` // maximum archive/unarchive size in GB. 0 means no limit. (default: 20)
|
|
Filesystem Filesystem `json:"filesystem"` // filesystem settings
|
|
IndexSqlConfig IndexSqlConfig `json:"indexSqlConfig"` // Index database SQL configuration
|
|
// not exposed to config
|
|
SourceMap map[string]*Source `json:"-" validate:"omitempty"` // uses realpath as key
|
|
NameToSource map[string]*Source `json:"-" validate:"omitempty"` // uses name as key
|
|
DatabaseV2 Database `json:"database"` // SQLite database configuration
|
|
}
|
|
|
|
type ActivityConfig struct {
|
|
Disabled bool `json:"disabled"` // disable semantic activity audit logging (default: false)
|
|
RetentionDays int `json:"retentionDays"` // purge activity rows older than this many days (default 30)
|
|
FlushIntervalSeconds int `json:"flushIntervalSeconds"` // buffer flush interval in seconds (default 10)
|
|
MaxBufferSize int `json:"maxBufferSize"` // max in-memory buffer before immediate flush (default 10000)
|
|
}
|
|
|
|
type QuotasConfig struct {
|
|
FlushIntervalSeconds int `json:"flushIntervalSeconds"` // default 10
|
|
FlushMaxBuffers int `json:"flushMaxBuffers"` // default 500
|
|
}
|
|
|
|
type Database struct {
|
|
Path string `json:"path"` // path to SQLite database file
|
|
MigrateFrom string `json:"migrateFrom"` // path to legacy database file for migration (optional)
|
|
Activity ActivityConfig `json:"activity"` // activity audit logging configuration
|
|
Quotas QuotasConfig `json:"quotas"` // quota counter batch flush configuration
|
|
}
|
|
|
|
type Filesystem struct {
|
|
CreateFilePermission string `json:"createFilePermission" validate:"required,file_permission"` // Unix permissions like 644, 755, 2755 (default: 644)
|
|
CreateDirectoryPermission string `json:"createDirectoryPermission" validate:"required,file_permission"` // Unix permissions like 755, 2755, 1777 (default: 755)
|
|
}
|
|
|
|
// Index SQL startup integrity modes (IndexSqlConfig.StartupIntegrityCheck).
|
|
const (
|
|
// IndexStartupIntegrityQuickCheck runs PRAGMA quick_check (default). Slower on very large DBs but thorough.
|
|
IndexStartupIntegrityQuickCheck = "quickCheck"
|
|
// IndexStartupIntegrityProbe verifies sqlite_master and optionally one row read only; fast for large indexes.
|
|
IndexStartupIntegrityProbe = "probe"
|
|
// IndexStartupIntegrityOff skips startup checks beyond sql.Open Ping; least safe, fastest boot.
|
|
IndexStartupIntegrityOff = "off"
|
|
)
|
|
|
|
type IndexSqlConfig struct {
|
|
BatchSize int `json:"batchSize"` // number of items to batch in a single transaction, typically 500-5000. higher = faster but could use more memory.
|
|
CacheSizeMB int `json:"cacheSizeMB"` // size of the SQLite cache in MB
|
|
WalMode bool `json:"walMode"` // enable the more complex WAL journaling mode. Slower, more memory usage, but better for deployments with constant user activity.
|
|
DisableReuse bool `json:"disableReuse"` // enable to always create a new indexing database on startup.
|
|
FTS5 bool `json:"fts5"` // Enable FTS5 to provide faster search queries, but 40% slower indexing and 15% larger database size
|
|
StartupIntegrityCheck string `json:"startupIntegrityCheck,omitempty" validate:"omitempty,oneof=quickCheck probe off"` // the method used to check the integrity of the index database on startup (default: quickCheck)
|
|
}
|
|
|
|
type Integrations struct {
|
|
OnlyOffice OnlyOffice `json:"office" validate:"omitempty"`
|
|
Media Media `json:"media" validate:"omitempty"`
|
|
}
|
|
|
|
// OnlyOffice configures the office editor documents open in. Despite the
|
|
// type's name it is not tied to one product: product selects OnlyOffice Docs,
|
|
// driven through its own document API, or Collabora Online, driven through
|
|
// WOPI.
|
|
//
|
|
// onlyoffice secret is stored in the local.json file
|
|
// docker exec <containerID> /var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/local.json 'services.CoAuthoring.secret.session.string'
|
|
type OnlyOffice struct {
|
|
Url string `json:"url" validate:"required"` // The URL to the office editor (OnlyOffice Document Server or Collabora Online), needs to be accessible to the user.
|
|
InternalUrl string `json:"internalUrl"` // An optional internal address that the filebrowser server can use to communicate with the office editor, could be useful to bypass proxy.
|
|
Secret string `json:"secret" validate:"required_unless=Product collabora"` // secret: OnlyOffice only, the JWT secret shared with the Document Server. Unused with collabora: editing sessions are signed with a key derived from auth.key, and Collabora trusts FileBrowser through its storage.wopi.host allow-list, where FileBrowser's host must be added.
|
|
Product string `json:"product" validate:"omitempty,oneof=onlyoffice collabora"` // office editor behind url: onlyoffice (default) or collabora
|
|
TokenExpirationHours int `json:"tokenExpirationHours"` // collabora only: lifetime of an editing session, in hours (default: 10)
|
|
ViewOnly bool `json:"viewOnly"` // view only mode for the office editor
|
|
}
|
|
|
|
const (
|
|
OfficeProductOnlyOffice = "onlyoffice"
|
|
OfficeProductCollabora = "collabora"
|
|
)
|
|
|
|
// IsCollabora reports whether documents open in Collabora Online (WOPI)
|
|
// rather than in OnlyOffice Docs.
|
|
func (o OnlyOffice) IsCollabora() bool {
|
|
return o.Url != "" && o.Product == OfficeProductCollabora
|
|
}
|
|
|
|
type Media struct {
|
|
FfmpegPath string `json:"ffmpegPath"` // path to ffmpeg directory with ffmpeg and ffprobe (eg. /usr/local/bin)
|
|
// SkipHwCheck skips the ffmpeg hardware codec probe entirely (software-only).
|
|
// Config-only, not a runtime setting — advanced use, e.g. keeping the
|
|
// multi-second probe out of CI startup.
|
|
SkipHwCheck bool `json:"skipHwCheck"`
|
|
|
|
// The fields below are deprecated and migrated to runtime (DB-backed) media settings on
|
|
// first run. They are kept only to seed the database from an existing config.yaml.
|
|
|
|
Convert FfmpegConvert `json:"convert"` // deprecated: config for ffmpeg conversion settings. deprecated: manage via the admin media settings API
|
|
Debug bool `json:"debug"` // deprecated: output ffmpeg stdout for media integration. deprecated: manage via the admin media settings API
|
|
ExtractEmbeddedSubtitles bool `json:"extractEmbeddedSubtitles"` // deprecated: no longer configurable; embedded subtitles are always extracted
|
|
HardwareAcceleration bool `json:"hardwareAcceleration"` // deprecated: enable hardware acceleration for ffmpeg if available. deprecated: manage via the admin media settings API
|
|
Transcode FullAdminTranscode `json:"transcode"` // deprecated: HLS transcoding for media playback. deprecated: manage via the admin media settings API
|
|
|
|
// AccelDevice selects the acceleration device: "auto" (default), "software"/"cpu",
|
|
// "igpu", "dgpu", a Linux DRM render node (e.g. /dev/dri/renderD128), or a GPU
|
|
// name substring. Managed via the admin media settings API.
|
|
AccelDevice string `json:"accelDevice"` // deprecated: manage via the admin media settings API
|
|
AlwaysUseFfmpeg bool `json:"alwaysUseFfmpeg"` // deprecated: manage via the admin media settings API
|
|
AlwaysUseOnlyOffice bool `json:"alwaysUseOnlyOffice"` // deprecated: skip folio previews for office converter; manage via the admin media settings API
|
|
}
|
|
|
|
// FullAdminMedia holds every runtime (DB-backed) media integration setting.
|
|
// ADMIN ONLY: non-admins receive UserMedia instead. FfmpegPath is config-only and intentionally excluded.
|
|
// ImagePreview is derived at read time (see PrepMediaForFrontend) and is cleared before save.
|
|
type FullAdminMedia struct {
|
|
ImagePreview map[ImagePreviewType]bool `json:"imagePreview,omitempty"` // image formats that can be converted
|
|
Convert FfmpegConvert `json:"convert"` // config for ffmpeg conversion settings
|
|
Debug bool `json:"debug"` // output ffmpeg stdout for media integration -- careful can produces lots of output!
|
|
HardwareAcceleration bool `json:"hardwareAcceleration"` // enable hardware acceleration for ffmpeg if available
|
|
AccelDevice string `json:"accelDevice"` // acceleration device: "auto", "software"/"cpu", "igpu", "dgpu", a DRM render node, or a GPU name substring
|
|
AlwaysUseFfmpeg bool `json:"alwaysUseFfmpeg"` // skip the go-media fast path and use ffmpeg for all probe, metadata, subtitle, and thumbnail work (default: false)
|
|
AlwaysUseOnlyOffice bool `json:"alwaysUseOnlyOffice"` // skip folio document previews and use the office converter when configured (default: false)
|
|
Transcode FullAdminTranscode `json:"transcode"` // HLS transcoding for media playback
|
|
}
|
|
|
|
// UserTranscode is PUBLIC: transcode fields every authenticated user receives in
|
|
// the UserMedia payload. FullAdminTranscode embeds it, so the same JSON keys appear
|
|
// in both admin and user responses. Add a field here only if the UI reads it.
|
|
type UserTranscode struct {
|
|
Enabled bool `json:"enabled"` // enable HLS transcoding for authenticated playback (default: false)
|
|
MaxConcurrentPerUser int `json:"maxConcurrentPerUser"` // hard per-user concurrent transcode ceiling (default: 1)
|
|
EnabledProfiles []string `json:"enabledProfiles,omitempty"` // derived at read time (player-menu profile ids); never stored
|
|
}
|
|
|
|
// UserMedia is PUBLIC: the only media payload non-admin users receive.
|
|
// Add a top-level key here only if the player or general UI reads it.
|
|
type UserMedia struct {
|
|
Transcode UserTranscode `json:"transcode"`
|
|
ImagePreview map[ImagePreviewType]bool `json:"imagePreview"` // availability, derived at read time
|
|
}
|
|
|
|
// FullAdminTranscode configures authenticated HLS transcoding (disabled by default).
|
|
// ADMIN ONLY beyond the embedded UserTranscode fields.
|
|
type FullAdminTranscode struct {
|
|
// inline: flattens the public fields in YAML (config.yaml) the same way the embed
|
|
// flattens them in JSON, so config keys stay transcode.enabled, not transcode.UserTranscode.enabled.
|
|
UserTranscode `yaml:",inline"`
|
|
MaxConcurrent int `json:"maxConcurrent"` // global concurrent transcode sessions (default: 2)
|
|
CacheMaxSizeMB int `json:"cacheMaxSizeMB"` // disk cache size limit in MB; 0 = unlimited (default: 10240)
|
|
CacheRetentionH int `json:"cacheRetentionH"` // completed cache retention in hours (default: 24)
|
|
Profiles TranscodeProfiles `json:"profiles"` // per-profile transcode settings shown in the player menu
|
|
MaxResolution int `json:"maxResolution"` // superseded by profiles.<name>.maxResolution. deprecated: kept for config compatibility
|
|
EncoderBackend string `json:"encoderBackend"` // default video encoder backend for transcodes: "" (auto), "cpu", or an accel backend (nvenc, amf, qsv, vaapi, d3d12, videotoolbox)
|
|
ReadRate float64 `json:"readRate"` // VOD producer input pacing in Nx realtime (-readrate); unset or <1 clamps to >=1 (default: 2)
|
|
}
|
|
|
|
// TranscodeProfiles configures the player's transcode quality presets.
|
|
type TranscodeProfiles struct {
|
|
Quality TranscodeProfile `json:"quality"` // match the source unless capped
|
|
Balanced TranscodeProfile `json:"balanced"` // balanced quality and size
|
|
DataSaver TranscodeProfile `json:"datasaver"` // smallest output
|
|
}
|
|
|
|
// TranscodeProfile configures a single transcode quality preset.
|
|
type TranscodeProfile struct {
|
|
Enabled bool `json:"enabled"` // show this preset in the player menu (default: true)
|
|
MaxResolution int `json:"maxResolution"` // maximum output height in pixels; 0 = original
|
|
AvgBitrateKbps int `json:"avgBitrateKbps"` // average video bitrate in kbps; 0 = original
|
|
EncoderBackend string `json:"encoderBackend"` // encoder backend override; "" inherits transcode.encoderBackend
|
|
}
|
|
|
|
type FfmpegConvert struct {
|
|
ImagePreview map[ImagePreviewType]*bool `json:"imagePreview"` // supported image preview formats. defaults vary by type (see individual type docs)
|
|
VideoPreview map[VideoPreviewType]*bool `json:"videoPreview"` // supported video preview formats. defaults to true for all types unless explicitly disabled.
|
|
}
|
|
|
|
type ImagePreviewType string
|
|
|
|
const (
|
|
HEICImagePreview ImagePreviewType = "heic"
|
|
JXLImagePreview ImagePreviewType = "jxl"
|
|
JPEGImagePreview ImagePreviewType = "jpeg" // only used as fallback for JPEG formats that can't otherwise be decoded
|
|
//RAWImagePreview ImagePreviewType = "raw"
|
|
)
|
|
|
|
func (i ImagePreviewType) String() string {
|
|
return string(i)
|
|
}
|
|
|
|
// AllImagePreviewTypes contains all supported image preview types.
|
|
var AllImagePreviewTypes = []ImagePreviewType{
|
|
HEICImagePreview,
|
|
JXLImagePreview,
|
|
JPEGImagePreview,
|
|
//RAWImagePreview,
|
|
}
|
|
|
|
type VideoPreviewType string
|
|
|
|
const (
|
|
MP4VideoPreview VideoPreviewType = "mp4"
|
|
WebMVideoPreview VideoPreviewType = "webm"
|
|
MOVVideoPreview VideoPreviewType = "mov"
|
|
AVIVideoPreview VideoPreviewType = "avi"
|
|
MKVVideoPreview VideoPreviewType = "mkv"
|
|
FLVVideoPreview VideoPreviewType = "flv"
|
|
WMVVideoPreview VideoPreviewType = "wmv"
|
|
M4VVideoPreview VideoPreviewType = "m4v"
|
|
ThreeGPVideoPreview VideoPreviewType = "3gp"
|
|
ThreeGP2VideoPreview VideoPreviewType = "3g2"
|
|
TSVideoPreview VideoPreviewType = "ts"
|
|
M2TSVideoPreview VideoPreviewType = "m2ts"
|
|
VOBVideoPreview VideoPreviewType = "vob"
|
|
ASFVideoPreview VideoPreviewType = "asf"
|
|
MPGVideoPreview VideoPreviewType = "mpg"
|
|
MPEGVideoPreview VideoPreviewType = "mpeg"
|
|
F4VVideoPreview VideoPreviewType = "f4v"
|
|
OGVVideoPreview VideoPreviewType = "ogv"
|
|
)
|
|
|
|
func (v VideoPreviewType) String() string {
|
|
return string(v)
|
|
}
|
|
|
|
// AllVideoPreviewTypes contains all supported video preview types.
|
|
var AllVideoPreviewTypes = []VideoPreviewType{
|
|
MP4VideoPreview,
|
|
WebMVideoPreview,
|
|
MOVVideoPreview,
|
|
AVIVideoPreview,
|
|
MKVVideoPreview,
|
|
FLVVideoPreview,
|
|
WMVVideoPreview,
|
|
M4VVideoPreview,
|
|
ThreeGPVideoPreview,
|
|
ThreeGP2VideoPreview,
|
|
TSVideoPreview,
|
|
M2TSVideoPreview,
|
|
VOBVideoPreview,
|
|
ASFVideoPreview,
|
|
MPGVideoPreview,
|
|
MPEGVideoPreview,
|
|
F4VVideoPreview,
|
|
OGVVideoPreview,
|
|
}
|
|
|
|
type LogConfig struct {
|
|
Levels string `json:"levels" yaml:"levels"` // separated list of log levels to enable. (eg. "info|warning|error|debug")
|
|
ApiLevels string `json:"apiLevels" yaml:"apiLevels"` // separated list of log levels to enable for the API. (eg. "info|warning|error")
|
|
Output string `json:"output" yaml:"output"` // output location. (eg. "stdout" or "path/to/file.log")
|
|
NoColors bool `json:"noColors" yaml:"noColors"` // disable colors in the output
|
|
Json bool `json:"json" yaml:"json"` // output in json format
|
|
Utc bool `json:"utc" yaml:"utc"` // use UTC time in the output instead of local time.
|
|
ApiFilter string `json:"apiFilter" yaml:"apiFilter"` // regex filter that excludes matching full api paths from being logged. (eg. '/user\?id\=self') Defaults to '^/health|^/favicon.ico|^/static|^/public/static'
|
|
}
|
|
type Source struct {
|
|
Path string `json:"path" validate:"required"` // file system path. (Can be relative)
|
|
Name string `json:"name"` // display name
|
|
Config SourceConfig `json:"config,omitempty"`
|
|
}
|
|
|
|
type SourceConfig struct {
|
|
DenyByDefault bool `json:"denyByDefault,omitempty"` // deny access unless an "allow" access rule was specifically created.
|
|
Private bool `json:"private"` // designate as source as private -- currently just means no sharing permitted.
|
|
ReadOnly bool `json:"readOnly,omitempty"` // read-only source, changes from the UI, webdav, and API will be disabled.
|
|
Disabled bool `json:"disabled,omitempty"` // disable the source, this is useful so you don't need to remove it from the config file
|
|
Rules []ConditionalRule `json:"rules"` // list of item rules to apply to specific paths
|
|
DefaultUserScope string `json:"defaultUserScope"` // defaults to root of index "/" should match folders under path
|
|
DefaultEnabled bool `json:"defaultEnabled"` // should be added as a default source for new users?
|
|
CreateUserDir bool `json:"createUserDir"` // create a user directory for each user under defaultUserScope + username
|
|
UseLogicalSize bool `json:"useLogicalSize"` // calculate sizes based on logical size instead of disk utilization (du -sh), folders will be 0 bytes when empty.
|
|
// DefaultPermissions is the template for new user scopes on this source (also synced globally via Access settings).
|
|
DefaultPermissions users.SourceFilePermissions `json:"defaultPermissions,omitempty" yaml:"defaultPermissions,omitempty"`
|
|
// DefaultPermissionsFromConfig holds permission flags explicitly set under defaultPermissions in config YAML.
|
|
DefaultPermissionsFromConfig map[string]bool `json:"-"`
|
|
// hidden but used internally - optimized map lookups for conditional rules
|
|
ResolvedRules ResolvedRulesConfig `json:"-"`
|
|
}
|
|
|
|
type ConditionalRule struct {
|
|
NeverWatchPath string `json:"neverWatchPath"` // index the folder in the first pass to get included in search, but never re-indexed.
|
|
IncludeRootItem string `json:"includeRootItem"` // include only these items at root folder level
|
|
FileStartsWith string `json:"fileStartsWith"` // (global) exclude files that start with these prefixes. Eg. "archive-" or "backup-"
|
|
FolderStartsWith string `json:"folderStartsWith"` // (global) exclude folders that start with these prefixes. Eg. "archive-" or "backup-"
|
|
FileEndsWith string `json:"fileEndsWith"` // (global) exclude files that end with these suffixes. Eg. ".jpg" or ".txt"
|
|
FolderEndsWith string `json:"folderEndsWith"` // (global) exclude folders that end with these suffixes. Eg. ".thumbnails" or ".git"
|
|
FolderPath string `json:"folderPath"` // (global) exclude folders that match this path. Eg. "/path/to/folder" or "/path/to/folder/subfolder"
|
|
FilePath string `json:"filePath"` // (global) exclude files that match this path. Eg. "/path/to/file.txt" or "/path/to/file.txt/subfile.txt"
|
|
FileName string `json:"fileName"` // (global) exclude files that match these names. Eg. "file.txt" or "test.csv"
|
|
FolderName string `json:"folderName"` // (global) exclude folders that match these names. Eg. "folder" or "subfolder"
|
|
|
|
Viewable bool `json:"viewable"` // Enable viewing in UI but exclude from indexing
|
|
IgnoreHidden bool `json:"ignoreHidden"` // Excludes only hidden files and folders
|
|
IgnoreZeroSizeFolders bool `json:"ignoreZeroSizeFolders"` // Excludes only folders with 0 size
|
|
IgnoreSymlinks bool `json:"ignoreSymlinks"` // Excludes symbolic links
|
|
}
|
|
|
|
// ResolvedRulesConfig provides O(1) lookup performance for conditional rules.
|
|
// Maps are built from Rules during initialization.
|
|
type ResolvedRulesConfig struct {
|
|
// Exact match maps - O(1) lookup (only for names, not StartsWith/EndsWith)
|
|
FileNames map[string]ConditionalRule // key: file name
|
|
FolderNames map[string]ConditionalRule // key: folder name
|
|
|
|
// exact match for paths
|
|
FilePaths map[string]ConditionalRule // key: file path
|
|
FolderPaths map[string]ConditionalRule // key: folder path
|
|
|
|
FileEndsWith []ConditionalRule // list of item rules that have been resolved for specific paths
|
|
FolderEndsWith []ConditionalRule // list of item rules that have been resolved for specific paths
|
|
FileStartsWith []ConditionalRule // list of item rules that have been resolved for specific paths
|
|
FolderStartsWith []ConditionalRule // list of item rules that have been resolved for specific paths
|
|
|
|
// NeverWatch paths map - O(1) lookup for all paths with neverWatch: true
|
|
// This replaces the old NeverWatchPaths slice
|
|
NeverWatchPaths map[string]struct{} // key: full folder path
|
|
IncludeRootItems map[string]struct{} // key: inclusive root item
|
|
|
|
IgnoreAllHidden bool // Excludes all hidden files and folders
|
|
IgnoreAllZeroSizeFolders bool // Excludes all folders with 0 size
|
|
IgnoreAllSymlinks bool // Excludes all symbolic links
|
|
IndexingDisabled bool // Excludes all files and folders from indexing
|
|
NoRules bool // No rules are configured
|
|
}
|
|
|
|
type Frontend struct {
|
|
Name string `json:"name"` // display name, PWA installation name is capped at 30 characters
|
|
DisableDefaultLinks bool `json:"disableDefaultLinks"` // disable default links in the sidebar
|
|
DisableUsedPercentage bool `json:"disableUsedPercentage"` // disable used percentage for the sources in the sidebar
|
|
ExternalLinks []ExternalLink `json:"externalLinks"`
|
|
DisableNavButtons bool `json:"disableNavButtons"` // disable the nav buttons in the sidebar
|
|
Styling StylingConfig `json:"styling"`
|
|
Favicon string `json:"favicon"` // path to a favicon to use for the frontend
|
|
Description string `json:"description"` // description that shows up in html head meta description
|
|
LoginIcon string `json:"loginIcon"` // path to an image file for the login page icon
|
|
LoginButtonText string `json:"loginButtonText"` // text to display on the login button
|
|
OIDCLoginButtonText string `json:"oidcLoginButtonText"` // text to display on the OIDC login button
|
|
DisablePWAInstall bool `json:"disablePWAInstall"` // disable the PWA install button in the sidebar
|
|
}
|
|
|
|
type StylingConfig struct {
|
|
DisableEventBasedThemes bool `json:"disableEventThemes"` // disable the event based themes,
|
|
CustomCSS string `json:"customCSS"` // if a valid path to a css file is provided, it will be applied for all users. (eg. "reduce-rounded-corners.css")
|
|
CustomCSSRaw string `json:"-"` // The css raw content to use for the custom css.
|
|
LightBackground string `json:"lightBackground"` // specify a valid CSS color property value to use as the background color in light mode
|
|
DarkBackground string `json:"darkBackground"` // Specify a valid CSS color property value to use as the background color in dark mode
|
|
CustomThemes map[string]CustomTheme `json:"customThemes"` // A list of custom css files that each user can select to override the default styling. if "default" is key name then it will be the default option.
|
|
// In-memory (not exposed to config)
|
|
CustomThemeOptions map[string]CustomTheme `json:"-"` // not exposed
|
|
}
|
|
|
|
type CustomTheme struct {
|
|
Description string `json:"description"` // The description of the theme to display in the UI.
|
|
CSS string `json:"css,omitempty"` // The css file path and filename to use for the theme.
|
|
CssRaw string `json:"-"` // The css raw content to use for the theme.
|
|
}
|
|
|
|
type ExternalLink struct {
|
|
Text string `json:"text" validate:"required"` // the text to display on the link
|
|
Title string `json:"title"` // the title to display on hover
|
|
Url string `json:"url" validate:"required"` // the url to link to
|
|
}
|
|
|
|
// UserDefaultsAccountPermissions holds global permission settings (not per-source file operations).
|
|
type UserDefaultsAccountPermissions struct {
|
|
Api bool `json:"api"` // allow api access
|
|
Admin bool `json:"admin"` // allow admin access
|
|
Share bool `json:"share"` // allow sharing files
|
|
Realtime bool `json:"realtime"` // allow realtime updates
|
|
}
|
|
|
|
// UserDefaultsSidebar holds sidebar-related settings
|
|
type UserDefaultsSidebar struct {
|
|
DisableQuickToggles bool `json:"disableQuickToggles"` // disable the quick toggles in the sidebar
|
|
HideFileActions bool `json:"hideFileActions"` // hide the file actions in the sidebar
|
|
DisableHideOnPreview bool `json:"disableHideOnPreview"` // keep sidebar open when previewing files (was preview.disableHideSidebar)
|
|
Sticky bool `json:"sticky"` // keep sidebar open when navigating
|
|
HideFiles bool `json:"hideFiles"` // hide files in the sidebar tree navigation, when true, will show only directories
|
|
ShowTools *bool `json:"showTools"` // show sidebar links with category "tool"; default is true
|
|
}
|
|
|
|
// UserDefaultsListing holds file listing display settings
|
|
type UserDefaultsListing struct {
|
|
DeleteWithoutConfirming bool `json:"deleteWithoutConfirming"` // delete files without confirmation
|
|
PromptRightCloseButton bool `json:"promptRightCloseButton"` // show the prompts close button on the right
|
|
DateFormat bool `json:"dateFormat"` // when false, the date is relative, when true, the date is an exact timestamp
|
|
ShowHidden bool `json:"showHidden"` // show hidden files in the UI. On windows this includes files starting with a dot and windows hidden files
|
|
QuickDownload bool `json:"quickDownload"` // show icon to download in one click
|
|
ShowSelectMultiple bool `json:"showSelectMultiple"` // show select multiple files on desktop
|
|
SingleClick bool `json:"singleClick"` // open directory on single click, also enables middle click to open in new tab
|
|
HideFileExt string `json:"hideFileExt"` // space separated list of file extensions to hide in UI
|
|
ShowCopyPath bool `json:"showCopyPath"` // show copy path button in the context menu
|
|
ShowTypeColumn bool `json:"showTypeColumn"` // show the Type column in list and compact views
|
|
ShowCreationDateColumn bool `json:"showCreationDateColumn"` // show the Creation date column in list and compact views
|
|
DeleteAfterArchive bool `json:"deleteAfterArchive"` // delete source files after successful creation/extraction of archives
|
|
ViewMode string `json:"viewMode"` // view mode to use: eg. normal, list, grid, or compact
|
|
GallerySize int `json:"gallerySize"` // 0-9 - the size of the gallery thumbnails
|
|
NewFileTemplate []string `json:"newFileTemplate"` // list of custom filenames that will be used as template for new files
|
|
}
|
|
|
|
// UserDefaultsPreview holds preview-related settings
|
|
type UserDefaultsPreview struct {
|
|
Image *bool `json:"image"` // show thumbnails for image files
|
|
Video *bool `json:"video"` // show thumbnails for video files
|
|
Audio *bool `json:"audio"` // show thumbnails for audio files
|
|
MotionVideoPreview *bool `json:"motionVideoPreview"` // show multiple frames for videos in thumbnail preview when hovering
|
|
Office *bool `json:"office"` // show thumbnails for office files
|
|
PopUp *bool `json:"popup"` // show larger popup preview when hovering over thumbnail
|
|
DisablePreviewExt string `json:"disablePreviewExt"` // comma separated list of file extensions to disable preview for
|
|
HighQuality *bool `json:"highQuality"` // high quality preview thumbnails
|
|
Folder *bool `json:"folder"` // show thumbnails for folders that have previewable contents
|
|
Models *bool `json:"models"` // show live thumbnails for 3D models files
|
|
}
|
|
|
|
// UserDefaultsFileViewer holds file viewer/editor settings
|
|
type UserDefaultsFileViewer struct {
|
|
AutoplayMedia *bool `json:"autoplayMedia"` // autoplay media files in preview
|
|
DisableViewingExt string `json:"disableViewingExt"` // comma separated list of file extensions to disable viewing for
|
|
DisableOnlyOfficeExt string `json:"disableOnlyOfficeExt"` // list of file extensions to disable onlyoffice editor for
|
|
PreferEditorForMarkdown bool `json:"preferEditorForMarkdown"` // prefer editor first for markdown files instead of the Markdown Viewer
|
|
DebugOffice bool `json:"debugOffice"` // debug onlyoffice editor
|
|
}
|
|
|
|
// UserDefaultsSearch holds search-related settings
|
|
type UserDefaultsSearch struct {
|
|
DisableOptions bool `json:"disableOptions"` // disable the search options in the search bar
|
|
}
|
|
|
|
// UserDefaultsUI holds UI/appearance settings
|
|
type UserDefaultsUI struct {
|
|
DarkMode users.DarkMode `json:"darkMode"` // theme preference: "auto" (follow system), "dark", or "light"
|
|
ThemeColor string `json:"themeColor"` // theme color to use: eg. #ff0000, or var(--red), var(--purple), etc
|
|
CustomTheme string `json:"customTheme"` // Name of theme to use chosen from custom themes config
|
|
Locale string `json:"locale"` // language to use: eg. de, en, or fr
|
|
|
|
}
|
|
|
|
// UserDefaultsAccount holds account/security settings
|
|
type UserDefaultsAccount struct {
|
|
Permissions UserDefaultsAccountPermissions `json:"permissions"`
|
|
LockPassword bool `json:"lockPassword"` // disable the user from changing their password
|
|
RequirePasswordChange bool `json:"requirePasswordChange"` // force password change at next password login
|
|
DisableSettings bool `json:"disableSettings"` // disable the user from viewing the settings page
|
|
LoginMethod string `json:"loginMethod,omitempty"` // login method to use: eg. password, proxy, oidc
|
|
DisableUpdateNotifications bool `json:"disableUpdateNotifications"` // disable update notifications banner for admin users
|
|
ShowAdvancedProfile bool `json:"showAdvancedProfile"` // show advanced profile settings in the user profile page
|
|
MaxConcurrentTranscodes int `json:"maxConcurrentTranscodes"` // per-user concurrent transcode sessions (default: 1)
|
|
}
|
|
|
|
// UserDefaults is a type that holds the default values for some fields on User.
|
|
type UserDefaults struct {
|
|
Sidebar UserDefaultsSidebar `json:"sidebar,omitempty"`
|
|
Listing UserDefaultsListing `json:"listing,omitempty"`
|
|
Preview UserDefaultsPreview `json:"preview,omitempty"`
|
|
FileViewer UserDefaultsFileViewer `json:"fileViewer,omitempty"`
|
|
Search UserDefaultsSearch `json:"search,omitempty"`
|
|
UI UserDefaultsUI `json:"ui,omitempty"`
|
|
FileLoading users.FileLoading `json:"fileLoading,omitempty"`
|
|
Account UserDefaultsAccount `json:"account,omitempty"`
|
|
DefaultScopes []users.BackendScope `json:"-"`
|
|
}
|