[PR #2418] [MERGED] refactor: replace afero with minimal FileStorage interface #8251

Closed
opened 2026-04-20 18:06:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2418
Author: @tink-bot
Created: 3/19/2026
Status: Merged
Merged: 3/20/2026
Merged by: @kolaente

Base: mainHead: feat-replace-afero-s3


📝 Commits (5)

  • fbe0ace feat: replace afero-s3 with minimal S3 afero.Fs implementation
  • 42ac8f3 fix: handle S3 backend in user export download
  • 11c626a refactor: replace afero with FileStorage interface
  • 341393a fix: use file mime type instead of hardcoded application/zip in S3 export
  • 4d5c783 test: add FileStat assertion to validate storage path in attachment test

📊 Changes

19 files changed (+655 additions, -362 deletions)

View changed files

📝 go.mod (+4 -9)
📝 go.sum (+0 -156)
📝 pkg/files/filehandling.go (+13 -39)
📝 pkg/files/files.go (+6 -59)
📝 pkg/files/files_test.go (+25 -0)
📝 pkg/files/repair.go (+1 -1)
📝 pkg/files/s3_test.go (+3 -88)
pkg/files/storage.go (+31 -0)
pkg/files/storage_local.go (+68 -0)
pkg/files/storage_local_test.go (+89 -0)
pkg/files/storage_mem.go (+103 -0)
pkg/files/storage_mem_test.go (+103 -0)
pkg/files/storage_s3.go (+165 -0)
📝 pkg/models/project_duplicate.go (+15 -3)
📝 pkg/models/task_attachment_test.go (+6 -3)
📝 pkg/models/task_duplicate.go (+8 -1)
📝 pkg/modules/background/handler/background.go (+1 -1)
📝 pkg/routes/api/v1/task_attachment.go (+1 -1)
📝 pkg/routes/api/v1/user_export.go (+13 -1)

📄 Description

Replace the github.com/spf13/afero dependency (as a direct import) with a purpose-built FileStorage interface that only exposes the 5 operations Vikunja actually uses: Open, Write, Stat, Remove, MkdirAll.

Three implementations: localStorage (wraps os), s3Storage (uses AWS SDK v2 directly), memStorage (for tests). This eliminates the split between afs (afero) for reads/deletes and s3Client for writes, and removes 207 lines of afero shim code (s3fs.go).

Also fixes File.File field type from afero.File to io.ReadCloser (which is all consumers need), and fixes the duplication flows (project_duplicate.go, task_duplicate.go) that were broken on S3 by buffering file content into bytes.Reader.

Closes #2347
Closes https://github.com/go-vikunja/vikunja/pull/2348

Test plan

  • S3 integration tests require a live S3/MinIO endpoint (VIKUNJA_FILES_TYPE=s3)

🔄 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/2418 **Author:** [@tink-bot](https://github.com/tink-bot) **Created:** 3/19/2026 **Status:** ✅ Merged **Merged:** 3/20/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `feat-replace-afero-s3` --- ### 📝 Commits (5) - [`fbe0ace`](https://github.com/go-vikunja/vikunja/commit/fbe0ace1b96933edd7219d939fb3c7abee9a2847) feat: replace afero-s3 with minimal S3 afero.Fs implementation - [`42ac8f3`](https://github.com/go-vikunja/vikunja/commit/42ac8f3cd41d47f1767905e34d7d7e1568749a15) fix: handle S3 backend in user export download - [`11c626a`](https://github.com/go-vikunja/vikunja/commit/11c626a9258b26a910ceaffa5d7fe19b3d4e56db) refactor: replace afero with FileStorage interface - [`341393a`](https://github.com/go-vikunja/vikunja/commit/341393a5fdadcc155c132101bf74e036afb3cf5e) fix: use file mime type instead of hardcoded application/zip in S3 export - [`4d5c783`](https://github.com/go-vikunja/vikunja/commit/4d5c783bd6a9943bbde5dfe074e162edeaa11192) test: add FileStat assertion to validate storage path in attachment test ### 📊 Changes **19 files changed** (+655 additions, -362 deletions) <details> <summary>View changed files</summary> 📝 `go.mod` (+4 -9) 📝 `go.sum` (+0 -156) 📝 `pkg/files/filehandling.go` (+13 -39) 📝 `pkg/files/files.go` (+6 -59) 📝 `pkg/files/files_test.go` (+25 -0) 📝 `pkg/files/repair.go` (+1 -1) 📝 `pkg/files/s3_test.go` (+3 -88) ➕ `pkg/files/storage.go` (+31 -0) ➕ `pkg/files/storage_local.go` (+68 -0) ➕ `pkg/files/storage_local_test.go` (+89 -0) ➕ `pkg/files/storage_mem.go` (+103 -0) ➕ `pkg/files/storage_mem_test.go` (+103 -0) ➕ `pkg/files/storage_s3.go` (+165 -0) 📝 `pkg/models/project_duplicate.go` (+15 -3) 📝 `pkg/models/task_attachment_test.go` (+6 -3) 📝 `pkg/models/task_duplicate.go` (+8 -1) 📝 `pkg/modules/background/handler/background.go` (+1 -1) 📝 `pkg/routes/api/v1/task_attachment.go` (+1 -1) 📝 `pkg/routes/api/v1/user_export.go` (+13 -1) </details> ### 📄 Description Replace the `github.com/spf13/afero` dependency (as a direct import) with a purpose-built `FileStorage` interface that only exposes the 5 operations Vikunja actually uses: `Open`, `Write`, `Stat`, `Remove`, `MkdirAll`. Three implementations: `localStorage` (wraps `os`), `s3Storage` (uses AWS SDK v2 directly), `memStorage` (for tests). This eliminates the split between `afs` (afero) for reads/deletes and `s3Client` for writes, and removes 207 lines of afero shim code (`s3fs.go`). Also fixes `File.File` field type from `afero.File` to `io.ReadCloser` (which is all consumers need), and fixes the duplication flows (`project_duplicate.go`, `task_duplicate.go`) that were broken on S3 by buffering file content into `bytes.Reader`. Closes #2347 Closes https://github.com/go-vikunja/vikunja/pull/2348 ## Test plan - S3 integration tests require a live S3/MinIO endpoint (`VIKUNJA_FILES_TYPE=s3`) --- <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-20 18:06:56 -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#8251