mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-16 12:08:04 +00:00
Add RwMutexes to all collections. #116
This commit is contained in:
+4
-1
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/smira/aptly/database"
|
"github.com/smira/aptly/database"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
"log"
|
"log"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LocalRepo is a collection of packages created locally
|
// LocalRepo is a collection of packages created locally
|
||||||
@@ -88,6 +89,7 @@ func (repo *LocalRepo) RefKey() []byte {
|
|||||||
|
|
||||||
// LocalRepoCollection does listing, updating/adding/deleting of LocalRepos
|
// LocalRepoCollection does listing, updating/adding/deleting of LocalRepos
|
||||||
type LocalRepoCollection struct {
|
type LocalRepoCollection struct {
|
||||||
|
*sync.RWMutex
|
||||||
db database.Storage
|
db database.Storage
|
||||||
list []*LocalRepo
|
list []*LocalRepo
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,8 @@ type LocalRepoCollection struct {
|
|||||||
// NewLocalRepoCollection loads LocalRepos from DB and makes up collection
|
// NewLocalRepoCollection loads LocalRepos from DB and makes up collection
|
||||||
func NewLocalRepoCollection(db database.Storage) *LocalRepoCollection {
|
func NewLocalRepoCollection(db database.Storage) *LocalRepoCollection {
|
||||||
result := &LocalRepoCollection{
|
result := &LocalRepoCollection{
|
||||||
db: db,
|
RWMutex: &sync.RWMutex{},
|
||||||
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
blobs := db.FetchByPrefix([]byte("L"))
|
blobs := db.FetchByPrefix([]byte("L"))
|
||||||
|
|||||||
+4
-1
@@ -14,6 +14,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -648,6 +649,7 @@ func (p *PublishedRepo) RemoveFiles(publishedStorageProvider aptly.PublishedStor
|
|||||||
|
|
||||||
// PublishedRepoCollection does listing, updating/adding/deleting of PublishedRepos
|
// PublishedRepoCollection does listing, updating/adding/deleting of PublishedRepos
|
||||||
type PublishedRepoCollection struct {
|
type PublishedRepoCollection struct {
|
||||||
|
*sync.RWMutex
|
||||||
db database.Storage
|
db database.Storage
|
||||||
list []*PublishedRepo
|
list []*PublishedRepo
|
||||||
}
|
}
|
||||||
@@ -655,7 +657,8 @@ type PublishedRepoCollection struct {
|
|||||||
// NewPublishedRepoCollection loads PublishedRepos from DB and makes up collection
|
// NewPublishedRepoCollection loads PublishedRepos from DB and makes up collection
|
||||||
func NewPublishedRepoCollection(db database.Storage) *PublishedRepoCollection {
|
func NewPublishedRepoCollection(db database.Storage) *PublishedRepoCollection {
|
||||||
result := &PublishedRepoCollection{
|
result := &PublishedRepoCollection{
|
||||||
db: db,
|
RWMutex: &sync.RWMutex{},
|
||||||
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
blobs := db.FetchByPrefix([]byte("U"))
|
blobs := db.FetchByPrefix([]byte("U"))
|
||||||
|
|||||||
+4
-1
@@ -16,6 +16,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -593,6 +594,7 @@ func (repo *RemoteRepo) RefKey() []byte {
|
|||||||
|
|
||||||
// RemoteRepoCollection does listing, updating/adding/deleting of RemoteRepos
|
// RemoteRepoCollection does listing, updating/adding/deleting of RemoteRepos
|
||||||
type RemoteRepoCollection struct {
|
type RemoteRepoCollection struct {
|
||||||
|
*sync.RWMutex
|
||||||
db database.Storage
|
db database.Storage
|
||||||
list []*RemoteRepo
|
list []*RemoteRepo
|
||||||
}
|
}
|
||||||
@@ -600,7 +602,8 @@ type RemoteRepoCollection struct {
|
|||||||
// NewRemoteRepoCollection loads RemoteRepos from DB and makes up collection
|
// NewRemoteRepoCollection loads RemoteRepos from DB and makes up collection
|
||||||
func NewRemoteRepoCollection(db database.Storage) *RemoteRepoCollection {
|
func NewRemoteRepoCollection(db database.Storage) *RemoteRepoCollection {
|
||||||
result := &RemoteRepoCollection{
|
result := &RemoteRepoCollection{
|
||||||
db: db,
|
RWMutex: &sync.RWMutex{},
|
||||||
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
blobs := db.FetchByPrefix([]byte("R"))
|
blobs := db.FetchByPrefix([]byte("R"))
|
||||||
|
|||||||
+8
-5
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -131,12 +132,12 @@ func (s *Snapshot) Decode(input []byte) error {
|
|||||||
if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") {
|
if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") {
|
||||||
// probably it is broken DB from go < 1.2, try decoding w/o time.Time
|
// probably it is broken DB from go < 1.2, try decoding w/o time.Time
|
||||||
var snapshot11 struct {
|
var snapshot11 struct {
|
||||||
UUID string
|
UUID string
|
||||||
Name string
|
Name string
|
||||||
CreatedAt []byte
|
CreatedAt []byte
|
||||||
|
|
||||||
SourceKind string
|
SourceKind string
|
||||||
SourceIDs []string
|
SourceIDs []string
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +161,7 @@ func (s *Snapshot) Decode(input []byte) error {
|
|||||||
|
|
||||||
// SnapshotCollection does listing, updating/adding/deleting of Snapshots
|
// SnapshotCollection does listing, updating/adding/deleting of Snapshots
|
||||||
type SnapshotCollection struct {
|
type SnapshotCollection struct {
|
||||||
|
*sync.RWMutex
|
||||||
db database.Storage
|
db database.Storage
|
||||||
list []*Snapshot
|
list []*Snapshot
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,8 @@ type SnapshotCollection struct {
|
|||||||
// NewSnapshotCollection loads Snapshots from DB and makes up collection
|
// NewSnapshotCollection loads Snapshots from DB and makes up collection
|
||||||
func NewSnapshotCollection(db database.Storage) *SnapshotCollection {
|
func NewSnapshotCollection(db database.Storage) *SnapshotCollection {
|
||||||
result := &SnapshotCollection{
|
result := &SnapshotCollection{
|
||||||
db: db,
|
RWMutex: &sync.RWMutex{},
|
||||||
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
blobs := db.FetchByPrefix([]byte("S"))
|
blobs := db.FetchByPrefix([]byte("S"))
|
||||||
|
|||||||
Reference in New Issue
Block a user