@Summary Delete Published Repository @Description **Delete a published repository** @Description @Description Delete a distribution of a published repository and remove associated files. @Description @Description If no other published repositories share the same prefix, all files inside the prefix w
(c *gin.Context)
| 628 | // @Failure 500 {object} Error "Internal Error" |
| 629 | // @Router /api/publish/{prefix}/{distribution} [delete] |
| 630 | func apiPublishDrop(c *gin.Context) { |
| 631 | param := slashEscape(c.Params.ByName("prefix")) |
| 632 | storage, prefix := deb.ParsePrefix(param) |
| 633 | distribution := slashEscape(c.Params.ByName("distribution")) |
| 634 | |
| 635 | force := c.Request.URL.Query().Get("force") == "1" |
| 636 | skipCleanup := c.Request.URL.Query().Get("SkipCleanup") == "1" |
| 637 | |
| 638 | collectionFactory := context.NewCollectionFactory() |
| 639 | collection := collectionFactory.PublishedRepoCollection() |
| 640 | |
| 641 | published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution) |
| 642 | if err != nil { |
| 643 | AbortWithJSONError(c, http.StatusNotFound, fmt.Errorf("unable to drop: %s", err)) |
| 644 | return |
| 645 | } |
| 646 | |
| 647 | resources := []string{string(published.Key())} |
| 648 | // Non-MultiDist distributions share a single pool/ directory under the |
| 649 | // prefix. Acquire the prefix-level pool lock so that a drop cannot race |
| 650 | // with a concurrent update or drop of a sibling distribution during cleanup. |
| 651 | if !published.MultiDist { |
| 652 | resources = append(resources, deb.PrefixPoolLockKey(published.StoragePrefix())) |
| 653 | } |
| 654 | taskName := fmt.Sprintf("Delete published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution) |
| 655 | maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { |
| 656 | taskCollectionFactory := context.NewCollectionFactory() |
| 657 | taskCollection := taskCollectionFactory.PublishedRepoCollection() |
| 658 | |
| 659 | err := taskCollection.Remove(context, storage, prefix, distribution, |
| 660 | taskCollectionFactory, out, force, skipCleanup) |
| 661 | if err != nil { |
| 662 | return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to drop: %s", err) |
| 663 | } |
| 664 | |
| 665 | return &task.ProcessReturnValue{Code: http.StatusOK, Value: gin.H{}}, nil |
| 666 | }) |
| 667 | } |
| 668 | |
| 669 | // @Summary Add Source Component |
| 670 | // @Description **Add a source component to a published repo** |
nothing calls this directly
no test coverage detected