mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-27 13:57:46 +00:00
db batch may not be a global resource
This way db usage is safe.
This commit is contained in:
committed by
Lorenzo Bolla
parent
f7f42a9cd8
commit
1c7c07ace7
+4
-18
@@ -159,15 +159,9 @@ func (collection *LocalRepoCollection) Add(repo *LocalRepo) error {
|
||||
// Update stores updated information about repo in DB
|
||||
func (collection *LocalRepoCollection) Update(repo *LocalRepo) error {
|
||||
batch := collection.db.CreateBatch()
|
||||
err := batch.Put(repo.Key(), repo.Encode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
batch.Put(repo.Key(), repo.Encode())
|
||||
if repo.packageRefs != nil {
|
||||
err = batch.Put(repo.RefKey(), repo.packageRefs.Encode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
batch.Put(repo.RefKey(), repo.packageRefs.Encode())
|
||||
}
|
||||
return batch.Write()
|
||||
}
|
||||
@@ -252,15 +246,7 @@ func (collection *LocalRepoCollection) Drop(repo *LocalRepo) error {
|
||||
delete(collection.cache, repo.UUID)
|
||||
|
||||
batch := collection.db.CreateBatch()
|
||||
err = batch.Delete(repo.Key())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = batch.Delete(repo.RefKey())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
batch.Delete(repo.Key())
|
||||
batch.Delete(repo.RefKey())
|
||||
return batch.Write()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user