Add RwMutexes to all collections. #116

This commit is contained in:
Andrey Smirnov
2014-10-08 16:16:07 +04:00
parent 2ed76f1e4c
commit ac983ff65d
4 changed files with 20 additions and 8 deletions
+4 -1
View File
@@ -14,6 +14,7 @@ import (
"path/filepath"
"sort"
"strings"
"sync"
"time"
)
@@ -648,6 +649,7 @@ func (p *PublishedRepo) RemoveFiles(publishedStorageProvider aptly.PublishedStor
// PublishedRepoCollection does listing, updating/adding/deleting of PublishedRepos
type PublishedRepoCollection struct {
*sync.RWMutex
db database.Storage
list []*PublishedRepo
}
@@ -655,7 +657,8 @@ type PublishedRepoCollection struct {
// NewPublishedRepoCollection loads PublishedRepos from DB and makes up collection
func NewPublishedRepoCollection(db database.Storage) *PublishedRepoCollection {
result := &PublishedRepoCollection{
db: db,
RWMutex: &sync.RWMutex{},
db: db,
}
blobs := db.FetchByPrefix([]byte("U"))