add mutex fo safety working with files
This commit is contained in:
parent
6dd5085bf6
commit
f071cfaf24
@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
@ -27,6 +28,7 @@ type Amo struct {
|
||||
integrationSecret string
|
||||
rateLimiter *limiter.RateLimiter
|
||||
amoStorageURL string
|
||||
fileMutex sync.Mutex
|
||||
}
|
||||
|
||||
type AmoDeps struct {
|
||||
@ -579,6 +581,8 @@ func (a *Amo) downloadFile(urlFile string) (*os.File, error) {
|
||||
}
|
||||
|
||||
func (a *Amo) UploadFileToAmo(urlFile string, accessToken string) (*models.ValuesFile, error) {
|
||||
a.fileMutex.Lock()
|
||||
defer a.fileMutex.Unlock()
|
||||
localFile, err := a.downloadFile(urlFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user