[PR #2231] [MERGED] fix: invalidate upload avatar cache for all cached sizes #4002

Closed
opened 2026-03-22 14:58:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2231
Author: @kolaente
Created: 2/13/2026
Status: Merged
Merged: 2/13/2026
Merged by: @kolaente

Base: mainHead: fix-avatar-cache-invalidation


📝 Commits (3)

  • 7afa2f5 test: add failing test for upload avatar FlushCache
  • eb0dffc fix: use DelPrefix in upload avatar FlushCache to clear all cached sizes
  • 90f881d test(e2e): add Playwright test for avatar cache invalidation

📊 Changes

4 files changed (+91 additions, -1 deletions)

View changed files

📝 frontend/tests/e2e/user/settings.spec.ts (+48 -0)
frontend/tests/fixtures/image-blue.png (+0 -0)
📝 pkg/modules/avatar/upload/upload.go (+1 -1)
📝 pkg/modules/avatar/upload/upload_test.go (+42 -0)

📄 Description

Summary

  • The upload avatar provider's FlushCache was calling keyvalue.Del with the base key (avatar_upload_{userID}), but actual cache entries are stored with size suffixes (avatar_upload_{userID}_{size}). The delete targeted a key that never existed, so cached avatars were never invalidated on re-upload.
  • Changed keyvalue.Del to keyvalue.DelPrefix with a trailing _ to match and delete all size-variant cache entries at once, consistent with the gravatar provider's existing pattern.

Test plan

  • Unit test (TestFlushCache): populates cache with multiple size variants, calls FlushCache, asserts all entries are removed
  • Existing unit tests (TestGetAvatar) still pass
  • E2E test: uploads two different avatars in sequence and verifies the header avatar src changes after the second upload
  • mage lint passes
  • pnpm lint passes
  • Manual Playwright verification: red avatar → blue avatar updates immediately in the header

🔄 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/2231 **Author:** [@kolaente](https://github.com/kolaente) **Created:** 2/13/2026 **Status:** ✅ Merged **Merged:** 2/13/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-avatar-cache-invalidation` --- ### 📝 Commits (3) - [`7afa2f5`](https://github.com/go-vikunja/vikunja/commit/7afa2f5adf830d684359b7ba2f22d210dfef6f5e) test: add failing test for upload avatar FlushCache - [`eb0dffc`](https://github.com/go-vikunja/vikunja/commit/eb0dffc81ac5aa0c34df7ebf978dab1222f39519) fix: use DelPrefix in upload avatar FlushCache to clear all cached sizes - [`90f881d`](https://github.com/go-vikunja/vikunja/commit/90f881de676e25baf2b3b6eeb2c943521852a883) test(e2e): add Playwright test for avatar cache invalidation ### 📊 Changes **4 files changed** (+91 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `frontend/tests/e2e/user/settings.spec.ts` (+48 -0) ➕ `frontend/tests/fixtures/image-blue.png` (+0 -0) 📝 `pkg/modules/avatar/upload/upload.go` (+1 -1) 📝 `pkg/modules/avatar/upload/upload_test.go` (+42 -0) </details> ### 📄 Description ## Summary - The upload avatar provider's `FlushCache` was calling `keyvalue.Del` with the base key (`avatar_upload_{userID}`), but actual cache entries are stored with size suffixes (`avatar_upload_{userID}_{size}`). The delete targeted a key that never existed, so cached avatars were never invalidated on re-upload. - Changed `keyvalue.Del` to `keyvalue.DelPrefix` with a trailing `_` to match and delete all size-variant cache entries at once, consistent with the gravatar provider's existing pattern. ## Test plan - [x] Unit test (`TestFlushCache`): populates cache with multiple size variants, calls `FlushCache`, asserts all entries are removed - [x] Existing unit tests (`TestGetAvatar`) still pass - [x] E2E test: uploads two different avatars in sequence and verifies the header avatar `src` changes after the second upload - [x] `mage lint` passes - [x] `pnpm lint` passes - [x] Manual Playwright verification: red avatar → blue avatar updates immediately in the header --- <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-03-22 14:58:34 -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#4002