Backport #28428 by @KN4CK3R
There could be a nil pointer exception if the file is not found because
that specific error is suppressed but not handled.
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
(cherry picked from commit 97a0bf151a
)
This commit is contained in:
parent
fdf950398b
commit
160ef74363
4 changed files with 14 additions and 28 deletions
|
@ -82,10 +82,7 @@ func BuildAllRepositoryFiles(ctx context.Context, ownerID int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pf := range pfs {
|
for _, pf := range pfs {
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
if err := packages_service.DeletePackageFile(ctx, pf); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,12 +154,11 @@ func buildPackagesIndex(ctx context.Context, ownerID int64, repoVersion *package
|
||||||
pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, IndexFilename, fmt.Sprintf("%s|%s|%s", branch, repository, architecture))
|
pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, IndexFilename, fmt.Sprintf("%s|%s|%s", branch, repository, architecture))
|
||||||
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
||||||
return err
|
return err
|
||||||
|
} else if pf == nil {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
return packages_service.DeletePackageFile(ctx, pf)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return packages_model.DeleteFileByID(ctx, pf.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache data needed for all repository files
|
// Cache data needed for all repository files
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
container_model "code.gitea.io/gitea/models/packages/container"
|
container_model "code.gitea.io/gitea/models/packages/container"
|
||||||
container_module "code.gitea.io/gitea/modules/packages/container"
|
container_module "code.gitea.io/gitea/modules/packages/container"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
packages_service "code.gitea.io/gitea/services/packages"
|
||||||
|
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
)
|
)
|
||||||
|
@ -47,10 +48,7 @@ func cleanupExpiredUploadedBlobs(ctx context.Context, olderThan time.Duration) e
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pf := range pfs {
|
for _, pf := range pfs {
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
if err := packages_service.DeletePackageFile(ctx, pf); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,10 +110,7 @@ func BuildAllRepositoryFiles(ctx context.Context, ownerID int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pf := range pfs {
|
for _, pf := range pfs {
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
if err := packages_service.DeletePackageFile(ctx, pf); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,12 +179,11 @@ func buildPackagesIndices(ctx context.Context, ownerID int64, repoVersion *packa
|
||||||
pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, filename, key)
|
pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, filename, key)
|
||||||
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
||||||
return err
|
return err
|
||||||
|
} else if pf == nil {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
if err := packages_service.DeletePackageFile(ctx, pf); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,12 +281,11 @@ func buildReleaseFiles(ctx context.Context, ownerID int64, repoVersion *packages
|
||||||
pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, filename, distribution)
|
pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, filename, distribution)
|
||||||
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
||||||
return err
|
return err
|
||||||
|
} else if pf == nil {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
if err := packages_service.DeletePackageFile(ctx, pf); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,10 +148,7 @@ func BuildRepositoryFiles(ctx context.Context, ownerID int64) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, pf := range pfs {
|
for _, pf := range pfs {
|
||||||
if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil {
|
if err := packages_service.DeletePackageFile(ctx, pf); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue