mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-05 22:08:27 +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()
|
list.PrepareIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction, err := collection.db.OpenTransaction()
|
checksumStorage := checksumStorageProvider(collection.db)
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
defer transaction.Discard()
|
|
||||||
|
|
||||||
checksumStorage := checksumStorageProvider(transaction)
|
|
||||||
|
|
||||||
for _, file := range packageFiles {
|
for _, file := range packageFiles {
|
||||||
var (
|
var (
|
||||||
@@ -201,7 +195,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.UpdateInTransaction(p, transaction)
|
err = collection.Update(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reporter.Warning("Unable to save package %s: %s", p, err)
|
reporter.Warning("Unable to save package %s: %s", p, err)
|
||||||
failedFiles = append(failedFiles, file)
|
failedFiles = append(failedFiles, file)
|
||||||
@@ -227,6 +221,6 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
|||||||
processedFiles = append(processedFiles, candidateProcessedFiles...)
|
processedFiles = append(processedFiles, candidateProcessedFiles...)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = transaction.Commit()
|
err = nil // reset error as only failed files are reported
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user