[PR #2348] [CLOSED] feat: replace afero-s3 with minimal in-tree S3 implementation #5619

Closed
opened 2026-04-16 13:44:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2348
Author: @maggch97
Created: 3/3/2026
Status: Closed

Base: mainHead: feat/replace-afero-s3


📝 Commits (2)

  • 8228d2b feat: replace afero-s3 with minimal S3 afero.Fs implementation
  • 2aa7eba fix: handle S3 backend in user export download

📊 Changes

5 files changed (+222 additions, -11 deletions)

View changed files

📝 go.mod (+1 -4)
📝 go.sum (+0 -4)
📝 pkg/files/filehandling.go (+2 -3)
pkg/files/s3fs.go (+207 -0)
📝 pkg/routes/api/v1/user_export.go (+12 -0)

📄 Description

Summary

Replaces the third-party fclairamb/afero-s3 library (and its temporary fork) with a minimal in-tree afero.Fs implementation (~200 lines) that only supports the three S3 operations Vikunja actually uses:

  • OpenHeadObject (existence check) + lazy GetObject on first Read
  • RemoveHeadObject + DeleteObject
  • StatHeadObject

All other afero.Fs/afero.File methods return ErrS3NotSupported since they are never called in the S3 code path (writes already use direct PutObject).

Changes

  1. pkg/files/s3fs.go (new) — Minimal S3 afero.Fs + afero.File + os.FileInfo implementation
  2. pkg/files/filehandling.go — Replace aferos3.NewFsFromClient() with newS3Fs()
  3. pkg/routes/api/v1/user_export.go — Add S3 branch for export download (io.Copy instead of http.ServeContent which requires io.ReadSeeker)
  4. go.mod / go.sum — Remove fclairamb/afero-s3 dependency and replace directive

Why

  • Removes dependency on a library that caused a severe S3 read performance regression (#2313)
  • Removes the temporary fork replace directive
  • The full afero-s3 library implements ~400 lines of S3 operations we never use (Create, Mkdir, Rename, Chmod, Write streams, Readdir, etc.)
  • Our implementation is small enough to maintain in-tree with minimal effort

Closes #2347


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2348 **Author:** [@maggch97](https://github.com/maggch97) **Created:** 3/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/replace-afero-s3` --- ### 📝 Commits (2) - [`8228d2b`](https://github.com/go-vikunja/vikunja/commit/8228d2b4c8b3d2799800ca7abd281eb52355edf5) feat: replace afero-s3 with minimal S3 afero.Fs implementation - [`2aa7eba`](https://github.com/go-vikunja/vikunja/commit/2aa7eba92046a82391263e3d54144543a6f3d3a3) fix: handle S3 backend in user export download ### 📊 Changes **5 files changed** (+222 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `go.mod` (+1 -4) 📝 `go.sum` (+0 -4) 📝 `pkg/files/filehandling.go` (+2 -3) ➕ `pkg/files/s3fs.go` (+207 -0) 📝 `pkg/routes/api/v1/user_export.go` (+12 -0) </details> ### 📄 Description ## Summary Replaces the third-party `fclairamb/afero-s3` library (and its temporary fork) with a minimal in-tree `afero.Fs` implementation (~200 lines) that only supports the three S3 operations Vikunja actually uses: - **Open** → `HeadObject` (existence check) + lazy `GetObject` on first `Read` - **Remove** → `HeadObject` + `DeleteObject` - **Stat** → `HeadObject` All other `afero.Fs`/`afero.File` methods return `ErrS3NotSupported` since they are never called in the S3 code path (writes already use direct `PutObject`). ## Changes 1. **`pkg/files/s3fs.go`** (new) — Minimal S3 `afero.Fs` + `afero.File` + `os.FileInfo` implementation 2. **`pkg/files/filehandling.go`** — Replace `aferos3.NewFsFromClient()` with `newS3Fs()` 3. **`pkg/routes/api/v1/user_export.go`** — Add S3 branch for export download (`io.Copy` instead of `http.ServeContent` which requires `io.ReadSeeker`) 4. **`go.mod` / `go.sum`** — Remove `fclairamb/afero-s3` dependency and `replace` directive ## Why - Removes dependency on a library that caused a severe S3 read performance regression (#2313) - Removes the temporary fork `replace` directive - The full afero-s3 library implements ~400 lines of S3 operations we never use (Create, Mkdir, Rename, Chmod, Write streams, Readdir, etc.) - Our implementation is small enough to maintain in-tree with minimal effort Closes #2347 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 13:44:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#5619