mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-29 00:25:19 +00:00
fix: eliminate nested database sessions to prevent table locks
Refactor functions that created their own sessions when called from within existing transactions, which caused "database table is locked" errors in SQLite's shared-cache mode. Changes: - Add files.CreateWithSession() to reuse caller's session - Refactor DeleteBackgroundFileIfExists() to accept session parameter - Add variadic session parameter to notifications.Notify() and Notifiable.ShouldNotify() interface - Update all Notify callers (~17 sites) to pass their session through - Use files.CreateWithSession in SaveBackgroundFile and NewAttachment - Fix test code to commit sessions before assertions
This commit is contained in:
@@ -218,6 +218,8 @@ func TestGetOrCreateUser(t *testing.T) {
|
||||
teamData := getTeamDataFromToken(cl.VikunjaGroups, nil)
|
||||
err := models.SyncExternalTeamsForUser(s, u, teamData, "https://some.issuer", "OIDC")
|
||||
require.NoError(t, err)
|
||||
err = s.Commit()
|
||||
require.NoError(t, err)
|
||||
|
||||
db.AssertMissing(t, "team_members", map[string]interface{}{
|
||||
"team_id": 14,
|
||||
|
||||
Reference in New Issue
Block a user