Compare commits

...

2 Commits

Author SHA1 Message Date
Derrick Hammer 9254dc20c8
fix: use decodedHash.HashBytes() 2024-03-28 21:48:13 -04:00
Derrick Hammer fffe769ccf
fix: use mapKey as a string 2024-03-28 21:47:48 -04:00
1 changed files with 5 additions and 4 deletions

View File

@ -496,11 +496,12 @@ func (t *TusHandler) worker() {
mapKey := append([]byte{}, decodedHash.HashBytes()...) mapKey := append([]byte{}, decodedHash.HashBytes()...)
mapKey = append(mapKey, []byte(info.Upload.ID)...) mapKey = append(mapKey, []byte(info.Upload.ID)...)
if _, ok := t.uploadMutexMap.Load(mapKey); !ok { mapKeyStr := string(mapKey)
t.uploadMutexMap.Store(mapKey, &sync.Mutex{}) if _, ok := t.uploadMutexMap.Load(mapKeyStr); !ok {
t.uploadMutexMap.Store(mapKeyStr, &sync.Mutex{})
} }
mutex, _ := t.uploadMutexMap.Load(mapKey) mutex, _ := t.uploadMutexMap.Load(mapKeyStr)
mutex.(*sync.Mutex).Lock() mutex.(*sync.Mutex).Lock()
exists, _ := t.UploadExists(ctx, decodedHash.HashBytes()) exists, _ := t.UploadExists(ctx, decodedHash.HashBytes())
@ -511,7 +512,7 @@ func (t *TusHandler) worker() {
continue continue
} }
_, err = t.CreateUpload(ctx, mapKey, info.Upload.ID, uploaderID, uploaderIP, t.storageProtocol.Name()) _, err = t.CreateUpload(ctx, decodedHash.HashBytes(), info.Upload.ID, uploaderID, uploaderIP, t.storageProtocol.Name())
mutex.(*sync.Mutex).Unlock() mutex.(*sync.Mutex).Unlock()
if err != nil { if err != nil {
errorResponse.Body = "Could not create tus upload" errorResponse.Body = "Could not create tus upload"