Skip to content

feat: auto disk usage limit mode - #56

Merged
pcfreak30 merged 1 commit into
developfrom
feat/auto-disk-limit
Jul 19, 2026
Merged

feat: auto disk usage limit mode#56
pcfreak30 merged 1 commit into
developfrom
feat/auto-disk-limit

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented Jul 19, 2026

Copy link
Copy Markdown
Member

What this does

Adds an automatic disk usage limit mode using real-time disk capacity via gopsutil. The setting is now a string with three modes:

Value Behavior
auto 80% of total disk capacity (default)
0 Unlimited (no limit)
N Fixed limit in gigabytes (e.g. 100 for 100 GB)

Why a string type

The old uint64 type could only express a fixed byte limit or 0 (unlimited). Adding auto required a sentinel value or a separate flag. Using a string keeps the config surface minimal and self-describing.

Backward compatibility

  • Existing configs with YAML numbers (disk_usage_limit: 100 or 100) continue to work via a mapstructure decode hook.
  • Environment variable overrides work unchanged.
  • Empty/missing defaults to auto.

Files changed

  • internal/config/config.go/config_test.go — DiskUsageLimit type, auto resolution, tests
  • internal/backend/factory.go — wiring to s3d factory
  • internal/handlers/handlers.go, handlers_config.go — API type/validation
  • internal/views/settings.templ — three-mode UI selector
  • web/src/pages/settings.ts, utils.ts — frontend state management
  • go.mod/go.sum — gopsutil/v4 dependency

@kody-ai

This comment has been minimized.

Comment thread internal/config/config.go Outdated

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from d8f54d8 to 4557341 Compare July 19, 2026 06:08
@kody-ai

This comment has been minimized.

Comment thread internal/backend/factory.go Outdated
Comment thread web/src/pages/settings.ts Outdated

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from 4557341 to dd6f937 Compare July 19, 2026 06:15
@kody-ai

This comment has been minimized.

@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from dd6f937 to fce7a34 Compare July 19, 2026 06:20
@kody-ai

This comment has been minimized.

Comment thread internal/config/config.go Outdated
@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from fce7a34 to 56fbfc1 Compare July 19, 2026 06:26
@kody-ai

This comment has been minimized.

@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from 56fbfc1 to 877cb8e Compare July 19, 2026 06:42
@kody-ai

This comment has been minimized.

Comment thread internal/backend/factory.go Outdated
@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from 877cb8e to ffd604a Compare July 19, 2026 06:50
@kody-ai

This comment has been minimized.

Comment thread internal/handlers/handlers_config.go Outdated
Add an automatic disk usage limit mode that dynamically calculates the
maximum upload space based on 80% of total disk capacity. The limit value
is now a string to support three modes:

- auto  → 80% of total disk capacity (default)
- 0     → unlimited
- N     → fixed limit in GB

Changes:
- config.DiskUsageLimit: new custom type with JSON/koanf hooks
- mapstructure decode hook for backward-compat with YAML numbers
- backend factory: resolve auto limits via gopsutil/disk
- handlers: validate incoming disk limit values
- frontend: three-mode selector (auto / unlimited / custom)
- gopsutil v4 dependency added

No breaking changes: existing configs with numeric disk_usage_limit
continue to work.
@pcfreak30
pcfreak30 force-pushed the feat/auto-disk-limit branch from ffd604a to fab142a Compare July 19, 2026 07:02
@kody-ai

kody-ai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@github-actions

Copy link
Copy Markdown

Docker image for testing

Pull the image for this PR:

docker pull ghcr.io/lumeweb/s3-server:sha-68f3c67

Or use in docker-compose:

services:
  s3-server:
    image: ghcr.io/lumeweb/s3-server:sha-68f3c67

The image is rebuilt on every push to this PR's branch.

@pcfreak30
pcfreak30 marked this pull request as ready for review July 19, 2026 07:08
@pcfreak30
pcfreak30 merged commit 98eb31e into develop Jul 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant