aboutsummaryrefslogtreecommitdiffstats
path: root/services/packages/cargo
diff options
context:
space:
mode:
authormerlleu <r.langdorph@gmail.com>2023-10-24 05:26:38 +0200
committerGitHub <noreply@github.com>2023-10-24 03:26:38 +0000
commit796ff26e0e9de8dc746064e57db13518dedcf671 (patch)
treec30c6deae48ad317d7d25168c34386b2e60f6cc4 /services/packages/cargo
parentce83609ff636f4c09d91ac53bee75a350bb571d6 (diff)
downloadgitea-796ff26e0e9de8dc746064e57db13518dedcf671.tar.gz
gitea-796ff26e0e9de8dc746064e57db13518dedcf671.zip
Do not force creation of _cargo-index repo on publish (#27266)
Hello there, Cargo Index over HTTP is now prefered over git for package updates: we should not force users who do not need the GIT repo to have the repo created/updated on each publish (it can still be created in the packages settings). The current behavior when publishing is to check if the repo exist and create it on the fly if not, then update it's content. Cargo HTTP Index does not rely on the repo itself so this will be useless for everyone not using the git protocol for cargo registry. This PR only disable the creation on the fly of the repo when publishing a crate. This is linked to #26844 (error 500 when trying to publish a crate if user is missing write access to the repo) because it's now optional. --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'services/packages/cargo')
-rw-r--r--services/packages/cargo/index.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/services/packages/cargo/index.go b/services/packages/cargo/index.go
index 0561f168e1..8164ffb01c 100644
--- a/services/packages/cargo/index.go
+++ b/services/packages/cargo/index.go
@@ -106,10 +106,16 @@ func RebuildIndex(ctx context.Context, doer, owner *user_model.User) error {
)
}
-func AddOrUpdatePackageIndex(ctx context.Context, doer, owner *user_model.User, packageID int64) error {
- repo, err := getOrCreateIndexRepository(ctx, doer, owner)
+func UpdatePackageIndexIfExists(ctx context.Context, doer, owner *user_model.User, packageID int64) error {
+ // We do not want to force the creation of the repo here
+ // cargo http index does not rely on the repo itself,
+ // so if the repo does not exist, we just do nothing.
+ repo, err := repo_model.GetRepositoryByOwnerAndName(ctx, owner.Name, IndexRepositoryName)
if err != nil {
- return err
+ if errors.Is(err, util.ErrNotExist) {
+ return nil
+ }
+ return fmt.Errorf("GetRepositoryByOwnerAndName: %w", err)
}
p, err := packages_model.GetPackageByID(ctx, packageID)