Skip to content

Commit

Permalink
Fixes #309: Handle 404 upon repository drop
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Nov 4, 2022
1 parent c879f1c commit a2f6a1d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,20 @@ class SonatypeClient(

def dropStage(currentProfile: StagingProfile, repo: StagingRepositoryProfile): Response = {
info(s"Dropping staging repository $repo")
val ret = httpClient.call[Map[String, StageTransitionRequest], Response](
Http.POST(s"${pathPrefix}/staging/profiles/${repo.profileId}/drop"),
newStageTransitionRequest(currentProfile, repo)
)
if (ret.statusCode != HttpStatus.Created_201.code) {
throw SonatypeException(STAGE_FAILURE, s"Failed to drop the repository. [${ret.status}]: ${ret.contentString}")
try {
val ret = httpClient.call[Map[String, StageTransitionRequest], Response](
Http.POST(s"${pathPrefix}/staging/profiles/${repo.profileId}/drop"),
newStageTransitionRequest(currentProfile, repo)
)
if (ret.statusCode != HttpStatus.Created_201.code) {
throw SonatypeException(STAGE_FAILURE, s"Failed to drop the repository. [${ret.status}]: ${ret.contentString}")
}
ret
} catch {
case e: HttpClientException if e.status == HttpStatus.NotFound_404 =>
warn(s"Staging repository ${repo.profileId} is not found. It might have been already dropped: ${e.getMessage}")
e.response.toHttpResponse
}
ret
}

private def newStageTransitionRequest(
Expand Down

0 comments on commit a2f6a1d

Please sign in to comment.