diff --git a/api/publish.go b/api/publish.go index 665cebed6..1f2f38be0 100644 --- a/api/publish.go +++ b/api/publish.go @@ -340,6 +340,8 @@ func apiPublishUpdateSwitch(c *gin.Context) { resources = append(resources, string(published.Key())) taskName := fmt.Sprintf("Update published %s (%s): %s", published.SourceKind, strings.Join(updatedComponents, " "), strings.Join(updatedSnapshots, ", ")) maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + context.PublishMutex.Lock() + defer context.PublishMutex.Unlock() err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite) if err != nil { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err) diff --git a/context/context.go b/context/context.go index d80528a54..c6df884e1 100644 --- a/context/context.go +++ b/context/context.go @@ -40,6 +40,7 @@ type AptlyContext struct { flags, globalFlags *flag.FlagSet configLoaded bool + PublishMutex sync.Mutex progress aptly.Progress downloader aptly.Downloader taskList *task.List @@ -593,6 +594,7 @@ func NewContext(flags *flag.FlagSet) (*AptlyContext, error) { var err error context := &AptlyContext{ + PublishMutex: sync.Mutex{}, flags: flags, globalFlags: flags, dependencyOptions: -1,