From 6adeacf8ce73b619ea85fd2d8e460ec4439d0102 Mon Sep 17 00:00:00 2001 From: Alexander Ackermann Date: Wed, 14 Oct 2026 09:36:24 +0200 Subject: [PATCH] feat: expose the default project space quota in the capabilities --- services/frontend/pkg/config/config.go | 1 + .../pkg/config/defaults/defaultconfig.go | 1 + services/frontend/pkg/revaconfig/config.go | 21 ++++++++++++++----- services/graph/pkg/config/config.go | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/services/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index e2bfb6a67b..1c926cfdc1 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -26,6 +26,7 @@ type Config struct { SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"FRONTEND_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token." introductionVersion:"1.0.0"` MaxQuota uint64 `yaml:"max_quota" env:"OC_SPACES_MAX_QUOTA;FRONTEND_MAX_QUOTA" desc:"Set the global max quota value in bytes. A value of 0 equals unlimited. The value is provided via capabilities." introductionVersion:"1.0.0"` + DefaultQuota string `yaml:"default_quota" env:"OC_SPACES_DEFAULT_QUOTA;FRONTEND_DEFAULT_QUOTA" desc:"Set the default quota in bytes for new project spaces. A value of 0 or an invalid value means no default quota. The value is provided via capabilities and must match the default quota of the graph service." introductionVersion:"%%NEXT%%"` UploadMaxChunkSize int `yaml:"upload_max_chunk_size" env:"FRONTEND_UPLOAD_MAX_CHUNK_SIZE" desc:"Sets the max chunk sizes in bytes for uploads via the clients." introductionVersion:"1.0.0"` UploadHTTPMethodOverride string `yaml:"upload_http_method_override" env:"FRONTEND_UPLOAD_HTTP_METHOD_OVERRIDE" desc:"Advise TUS to replace PATCH requests by POST requests." introductionVersion:"1.0.0"` DefaultUploadProtocol string `yaml:"default_upload_protocol" env:"FRONTEND_DEFAULT_UPLOAD_PROTOCOL" desc:"The default upload protocol to use in clients. Currently only 'tus' is available. See the developer API documentation for more details about TUS." introductionVersion:"1.0.0"` diff --git a/services/frontend/pkg/config/defaults/defaultconfig.go b/services/frontend/pkg/config/defaults/defaultconfig.go index 30341dc332..d652301957 100644 --- a/services/frontend/pkg/config/defaults/defaultconfig.go +++ b/services/frontend/pkg/config/defaults/defaultconfig.go @@ -82,6 +82,7 @@ func DefaultConfig() *config.Config { Reva: shared.DefaultRevaConfig(), PublicURL: "https://localhost:9200", UploadMaxChunkSize: 1e+7, + DefaultQuota: "1000000000", UploadHTTPMethodOverride: "", DefaultUploadProtocol: "tus", DefaultLinkPermissions: 1, diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index afa7018f8b..03f57d9ebb 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -295,11 +295,12 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string }, }, "spaces": map[string]any{ - "version": "1.0.0", - "enabled": true, - "projects": true, - "share_jail": true, - "max_quota": cfg.MaxQuota, + "version": "1.0.0", + "enabled": true, + "projects": true, + "share_jail": true, + "max_quota": cfg.MaxQuota, + "default_quota": parseQuota(cfg.DefaultQuota), }, "theme": capabilities.Default().Theme, "search": map[string]any{ @@ -444,3 +445,13 @@ func passwordPolicyConfig(cfg *config.Config) (map[string]any, error) { "banned_passwords_list": bannedPasswordsList, }, nil } + +// parseQuota parses a quota in bytes the same way the graph service does. +// Empty, invalid or negative values result in 0, which means no default quota. +func parseQuota(quota string) uint64 { + q, err := strconv.ParseInt(quota, 10, 64) + if err != nil || q < 0 { + return 0 + } + return uint64(q) +} diff --git a/services/graph/pkg/config/config.go b/services/graph/pkg/config/config.go index a1d0b16629..af603b46f3 100644 --- a/services/graph/pkg/config/config.go +++ b/services/graph/pkg/config/config.go @@ -51,7 +51,7 @@ type Config struct { type Spaces struct { WebDavBase string `yaml:"webdav_base" env:"OC_URL;GRAPH_SPACES_WEBDAV_BASE" desc:"The public facing URL of WebDAV." introductionVersion:"1.0.0"` WebDavPath string `yaml:"webdav_path" env:"GRAPH_SPACES_WEBDAV_PATH" desc:"The WebDAV sub-path for spaces." introductionVersion:"1.0.0"` - DefaultQuota string `yaml:"default_quota" env:"GRAPH_SPACES_DEFAULT_QUOTA" desc:"The default quota in bytes." introductionVersion:"1.0.0"` + DefaultQuota string `yaml:"default_quota" env:"OC_SPACES_DEFAULT_QUOTA;GRAPH_SPACES_DEFAULT_QUOTA" desc:"The default quota in bytes." introductionVersion:"1.0.0"` ExtendedSpacePropertiesCacheTTL int `yaml:"extended_space_properties_cache_ttl" env:"GRAPH_SPACES_EXTENDED_SPACE_PROPERTIES_CACHE_TTL" desc:"Max TTL in seconds for the spaces property cache." introductionVersion:"1.0.0"` UsersCacheTTL int `yaml:"users_cache_ttl" env:"GRAPH_SPACES_USERS_CACHE_TTL" desc:"Max TTL in seconds for the spaces users cache." introductionVersion:"1.0.0"` GroupsCacheTTL int `yaml:"groups_cache_ttl" env:"GRAPH_SPACES_GROUPS_CACHE_TTL" desc:"Max TTL in seconds for the spaces groups cache." introductionVersion:"1.0.0"`