From fb6b4f65ac4a5f26f43096da374340e514c838ad Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Sun, 20 Sep 2020 22:04:42 +0200 Subject: [PATCH] Fix database lock when trying to write already existing redirect --- cache.go | 4 ++-- database.go | 2 +- hugo.go | 2 +- postsDb.go | 9 +++++++++ redirects.go | 7 +++++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cache.go b/cache.go index 8ed6a1a..6f4db27 100644 --- a/cache.go +++ b/cache.go @@ -81,6 +81,7 @@ func getCache(context context.Context, path string) (creationTime int64, header func saveCache(path string, now time.Time, header map[string][]string, body []byte) { headerBytes, _ := json.Marshal(header) startWritingToDb() + defer finishWritingToDb() tx, err := appDb.Begin() if err != nil { return @@ -88,16 +89,15 @@ func saveCache(path string, now time.Time, header map[string][]string, body []by _, _ = tx.Exec("delete from cache where time