@Summary Update Published Repository @Description **Update a published repository** @Description @Description Publish pending source component changes which were added with `Add/Remove/Replace Source Components` @Description @Description See also: `aptly publish update` @Tags Publish @Param prefix p
(c *gin.Context)
| 1131 | // @Failure 500 {object} Error "Internal Error" |
| 1132 | // @Router /api/publish/{prefix}/{distribution}/update [post] |
| 1133 | func apiPublishUpdate(c *gin.Context) { |
| 1134 | var b publishedRepoUpdateParams |
| 1135 | |
| 1136 | param := slashEscape(c.Params.ByName("prefix")) |
| 1137 | storage, prefix := deb.ParsePrefix(param) |
| 1138 | distribution := slashEscape(c.Params.ByName("distribution")) |
| 1139 | |
| 1140 | if c.Bind(&b) != nil { |
| 1141 | return |
| 1142 | } |
| 1143 | |
| 1144 | signer, err := getSigner(&b.Signing) |
| 1145 | if err != nil { |
| 1146 | AbortWithJSONError(c, http.StatusInternalServerError, fmt.Errorf("unable to initialize GPG signer: %s", err)) |
| 1147 | return |
| 1148 | } |
| 1149 | |
| 1150 | collectionFactory := context.NewCollectionFactory() |
| 1151 | collection := collectionFactory.PublishedRepoCollection() |
| 1152 | |
| 1153 | // Load shallowly for 404 check, resource key, and task name. |
| 1154 | // Full load and field mutations happen inside the task. |
| 1155 | published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution) |
| 1156 | if err != nil { |
| 1157 | AbortWithJSONError(c, http.StatusNotFound, fmt.Errorf("unable to update: %s", err)) |
| 1158 | return |
| 1159 | } |
| 1160 | |
| 1161 | resources := []string{string(published.Key())} |
| 1162 | |
| 1163 | // Non-MultiDist distributions share a single pool/ directory under the |
| 1164 | // prefix. Acquire the prefix-level pool lock so that concurrent updates |
| 1165 | // on sibling distributions are serialised and cannot race during cleanup. |
| 1166 | if !published.MultiDist { |
| 1167 | resources = append(resources, deb.PrefixPoolLockKey(published.StoragePrefix())) |
| 1168 | } |
| 1169 | |
| 1170 | // Lock source repos / snapshots the same way apiPublishUpdateSwitch does, |
| 1171 | // because published.Update() reads from them and concurrent modification |
| 1172 | // would produce an inconsistent view. |
| 1173 | snapshotCollection := collectionFactory.SnapshotCollection() |
| 1174 | localRepoCollection := collectionFactory.LocalRepoCollection() |
| 1175 | |
| 1176 | if published.SourceKind == deb.SourceLocalRepo { |
| 1177 | for _, uuid := range published.Sources { |
| 1178 | repo, err2 := localRepoCollection.ByUUID(uuid) |
| 1179 | if err2 != nil { |
| 1180 | AbortWithJSONError(c, http.StatusNotFound, err2) |
| 1181 | return |
| 1182 | } |
| 1183 | resources = append(resources, string(repo.Key())) |
| 1184 | } |
| 1185 | } else if published.SourceKind == deb.SourceSnapshot { |
| 1186 | for _, uuid := range published.Sources { |
| 1187 | snapshot, err2 := snapshotCollection.ByUUID(uuid) |
| 1188 | if err2 != nil { |
| 1189 | AbortWithJSONError(c, http.StatusNotFound, err2) |
| 1190 | return |
nothing calls this directly
no test coverage detected