@@ -92,7 +92,7 @@ func presentRepo(r reposdb.Repo, ownerLogin string) repoResponse { |
| 92 | 92 | OwnerType: ownerType, |
| 93 | 93 | Description: r.Description, |
| 94 | 94 | Visibility: string(r.Visibility), |
| 95 | | - Private: r.Visibility != reposdb.RepoVisibilityPublic, |
| 95 | + Private: string(r.Visibility) == "private", |
| 96 | 96 | DefaultBranch: r.DefaultBranch, |
| 97 | 97 | Fork: r.ForkOfRepoID.Valid, |
| 98 | 98 | Archived: r.IsArchived, |
@@ -481,13 +481,16 @@ func (h *Handlers) repoPatch(w http.ResponseWriter, r *http.Request) { |
| 481 | 481 | } |
| 482 | 482 | if body.Archived != nil { |
| 483 | 483 | ldeps := lifecycle.Deps{Pool: h.d.Pool, RepoFS: h.d.RepoFS, Audit: h.d.Audit, Logger: h.d.Logger} |
| 484 | | - if *body.Archived && !repo.IsArchived { |
| 484 | + wantArchived := *body.Archived |
| 485 | + currentlyArchived := repo.IsArchived |
| 486 | + switch { |
| 487 | + case wantArchived && !currentlyArchived: |
| 485 | 488 | if err := lifecycle.Archive(r.Context(), ldeps, auth.UserID, repo.ID); err != nil { |
| 486 | 489 | h.d.Logger.ErrorContext(r.Context(), "api: archive", "error", err) |
| 487 | 490 | writeAPIError(w, http.StatusInternalServerError, "archive failed") |
| 488 | 491 | return |
| 489 | 492 | } |
| 490 | | - } else if !*body.Archived && repo.IsArchived { |
| 493 | + case !wantArchived && currentlyArchived: |
| 491 | 494 | if err := lifecycle.Unarchive(r.Context(), ldeps, auth.UserID, repo.ID); err != nil { |
| 492 | 495 | h.d.Logger.ErrorContext(r.Context(), "api: unarchive", "error", err) |
| 493 | 496 | writeAPIError(w, http.StatusInternalServerError, "unarchive failed") |