mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Fix publishing race condition
A race condition for publishing packages and
mirrors at the same time was introduced in
commit 77d7c38.
The problem is that when opening a leveldb transaction
and performing another 'put' to the db
the system freezes.
This commit is contained in:
@@ -71,13 +71,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
||||
list.PrepareIndex()
|
||||
}
|
||||
|
||||
transaction, err := collection.db.OpenTransaction()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer transaction.Discard()
|
||||
|
||||
checksumStorage := checksumStorageProvider(transaction)
|
||||
checksumStorage := checksumStorageProvider(collection.db)
|
||||
|
||||
for _, file := range packageFiles {
|
||||
var (
|
||||
@@ -201,7 +195,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
||||
continue
|
||||
}
|
||||
|
||||
err = collection.UpdateInTransaction(p, transaction)
|
||||
err = collection.Update(p)
|
||||
if err != nil {
|
||||
reporter.Warning("Unable to save package %s: %s", p, err)
|
||||
failedFiles = append(failedFiles, file)
|
||||
@@ -227,6 +221,6 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
||||
processedFiles = append(processedFiles, candidateProcessedFiles...)
|
||||
}
|
||||
|
||||
err = transaction.Commit()
|
||||
err = nil // reset error as only failed files are reported
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user