api: repo copy handle package not found

and add tests for error proper handling.
This commit is contained in:
André Roth committed 2024-07-24 21:19:47 +02:00
1 parent 49184c9163
commit fe25414b45
3 files changed
+11 -3

No files matched your search

+4
View File
@@ -524,6 +524,10 @@ func apiReposCopyPackage(c *gin.Context) {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("filter error: %s", err)
}
if toProcess.Len() == 0 {
return &task.ProcessReturnValue{Code: http.StatusUnprocessableEntity, Value: nil}, fmt.Errorf("no package found for filter: '%s'", fileName)
}
err = toProcess.ForEach(func(p *deb.Package) error {
err = dstList.Add(p)
if err != nil {