mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-26 13:47:40 +00:00
Don't use transactions when direct db access is enough
For read-only action transactions are not necessary and they risk to deadlock if multiple go-routines try to read the database.
This commit is contained in:
+1
-7
@@ -389,13 +389,7 @@ func (collection *SnapshotCollection) Len() int {
|
||||
|
||||
// Drop removes snapshot from collection
|
||||
func (collection *SnapshotCollection) Drop(snapshot *Snapshot) error {
|
||||
transaction, err := collection.db.OpenTransaction()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer transaction.Discard()
|
||||
|
||||
if _, err = transaction.Get(snapshot.Key()); err != nil {
|
||||
if _, err := collection.db.Get(snapshot.Key()); err != nil {
|
||||
if err == database.ErrNotFound {
|
||||
return errors.New("snapshot not found")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user