aboutsummaryrefslogtreecommitdiffstats
path: root/models/packages/package_file.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-04-28 23:51:36 +0200
committerGitHub <noreply@github.com>2023-04-28 17:51:36 -0400
commitbf77e2163b670797d5bf7199da88789968e47c61 (patch)
tree9cd8d0af2d05df59aa2169abeaa99ea7f6be45e3 /models/packages/package_file.go
parentbc4e06109dae33edc0a9a918f244563f05a1a353 (diff)
downloadgitea-bf77e2163b670797d5bf7199da88789968e47c61.tar.gz
gitea-bf77e2163b670797d5bf7199da88789968e47c61.zip
Add Debian package registry (#22854)
Co-authored-by: @awkwardbunny This PR adds a Debian package registry. You can follow [this tutorial](https://www.baeldung.com/linux/create-debian-package) to build a *.deb package for testing. Source packages are not supported at the moment and I did not find documentation of the architecture "all" and how these packages should be treated. --------- Co-authored-by: Brian Hong <brian@hongs.me> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models/packages/package_file.go')
-rw-r--r--models/packages/package_file.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/models/packages/package_file.go b/models/packages/package_file.go
index 97e7a0d407..337ab1135a 100644
--- a/models/packages/package_file.go
+++ b/models/packages/package_file.go
@@ -117,13 +117,15 @@ func DeleteFileByID(ctx context.Context, fileID int64) error {
// PackageFileSearchOptions are options for SearchXXX methods
type PackageFileSearchOptions struct {
- OwnerID int64
- PackageType string
- VersionID int64
- Query string
- CompositeKey string
- Properties map[string]string
- OlderThan time.Duration
+ OwnerID int64
+ PackageType string
+ VersionID int64
+ Query string
+ CompositeKey string
+ Properties map[string]string
+ OlderThan time.Duration
+ HashAlgorithmn string
+ Hash string
db.Paginator
}
@@ -182,6 +184,15 @@ func (opts *PackageFileSearchOptions) toConds() builder.Cond {
cond = cond.And(builder.Lt{"package_file.created_unix": time.Now().Add(-opts.OlderThan).Unix()})
}
+ if opts.Hash != "" && (opts.HashAlgorithmn == "md5" || opts.HashAlgorithmn == "sha1" || opts.HashAlgorithmn == "sha256" || opts.HashAlgorithmn == "sha512") {
+ innerCond := builder.
+ Expr("package_blob.id = package_file.blob_id").
+ And(builder.Eq{
+ "package_blob.hash_" + opts.HashAlgorithmn: opts.Hash,
+ })
+ cond = cond.And(builder.Exists(builder.Select("package_blob.id").From("package_blob").Where(innerCond)))
+ }
+
return cond
}