From 3eb5c44be311f10cd3f78019d2b713b8f13b11d8 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 30 Jun 2023 15:03:50 +0300 Subject: [PATCH] Fix attachment semaphore unlocking when download fails --- attachments.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachments.go b/attachments.go index 9526211..85a51a9 100644 --- a/attachments.go +++ b/attachments.go @@ -294,6 +294,7 @@ func (br *DiscordBridge) copyAttachmentToMatrix(intent *appservice.IntentAPI, ur } var semaWg sync.WaitGroup semaWg.Add(1) + defer semaWg.Done() go func() { semaWg.Wait() br.parallelAttachmentSemaphore.Release(attachmentSizeVal) @@ -321,7 +322,6 @@ func (br *DiscordBridge) copyAttachmentToMatrix(intent *appservice.IntentAPI, ur onceDBFile.Insert(nil) } br.attachmentTransfers.Delete(transferKey) - semaWg.Done() return }) }