diff options
| author | Sandro Jäckel <sandro.jaeckel@sap.com> | 2022-10-26 15:23:24 +0200 |
|---|---|---|
| committer | Sandro Jäckel <sandro.jaeckel@sap.com> | 2022-10-28 13:08:59 +0200 |
| commit | 82de494f495481b5ae016038c7020898a135c8dc (patch) | |
| tree | 820ea30f856dbe82bdeae84dba86d5361764d617 /account.go | |
| parent | 8b38a040830109f19550e7329b82ec5caf76b321 (diff) | |
| download | go-schwift-82de494f495481b5ae016038c7020898a135c8dc.tar.gz | |
Generate digest preferable with sha2, then sha512 and fallback to insecure sha1
Diffstat (limited to 'account.go')
| -rw-r--r-- | account.go | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -23,6 +23,7 @@ import ( "fmt" "net/http" "regexp" + "sync" ) // Account represents a Swift account. Instances are usually obtained by @@ -34,8 +35,9 @@ type Account struct { baseURL string name string //cache - headers *AccountHeaders - caps *Capabilities + headers *AccountHeaders + caps *Capabilities + capsMutex sync.Mutex } // IsEqualTo returns true if both Account instances refer to the same account. @@ -183,10 +185,10 @@ func (a *Account) Containers() *ContainerIterator { // Capabilities queries the GET /info endpoint of the Swift server providing // this account. Capabilities are cached, so the GET request will only be sent // once during the first call to this method. -// -// WARNING: This method is not thread-safe. Calling it concurrently on the same -// object results in undefined behavior. func (a *Account) Capabilities() (Capabilities, error) { + a.capsMutex.Lock() + defer a.capsMutex.Unlock() + if a.caps != nil { return *a.caps, nil } |
