diff --git a/export/export.go b/export/export.go index dc74eb0b6e1..5f27d10cf63 100644 --- a/export/export.go +++ b/export/export.go @@ -2,6 +2,7 @@ package export import ( "context" + "errors" "fmt" nanoid "github.com/matoous/go-nanoid" @@ -19,6 +20,8 @@ func getExportID(repo, branch, commitRef string) (string, error) { return fmt.Sprintf("%s-%s-%s-%s", repo, branch, commitRef, nid), nil } +var ErrExportInProgress = errors.New("export currently in progress") + // ExportBranchStart inserts a start task on branch, sets branch export state to pending. // It returns an error if an export is already in progress. func ExportBranchStart(paradeDB parade.Parade, cataloger catalog.Cataloger, repo, branch string) (string, error) { @@ -32,6 +35,9 @@ func ExportBranchStart(paradeDB parade.Parade, cataloger catalog.Cataloger, repo return "", err } err = cataloger.ExportState(repo, branch, commitRef, func(oldRef string, state catalog.CatalogBranchExportStatus) (newState catalog.CatalogBranchExportStatus, newMessage *string, err error) { + if state == catalog.ExportStatusInProgress { + return state, nil, ErrExportInProgress + } config, err := cataloger.GetExportConfigurationForBranch(repo, branch) if err != nil { return "", nil, err