Skip to content

Commit

Permalink
Fix temporary contents DB being left behind after publishing
Browse files Browse the repository at this point in the history
NB: Go `defer` order execution is reverse to the order `defer` statements
are executed.

So before the change, `Drop()` was called before `Close()`, which was no-op.

Change that to explicit order in single func, print errors if they happen.
  • Loading branch information
smira committed Apr 10, 2017
1 parent 7fd8bd0 commit a6541aa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions deb/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,17 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
if err != nil {
return err
}
defer tempDB.Close()
defer tempDB.Drop()
defer func() {
var e error
e = tempDB.Close()
if e != nil && progress != nil {
progress.Printf("failed to close temp DB: %s", err)
}
e = tempDB.Drop()
if e != nil && progress != nil {
progress.Printf("failed to drop temp DB: %s", err)
}
}()

if progress != nil {
progress.Printf("Loading packages...\n")
Expand Down

0 comments on commit a6541aa

Please sign in to comment.