Compare commits

..

3 Commits

Author SHA1 Message Date
4669546e2b updated Gradle version
All checks were successful
CI / build (push) Successful in 1m0s
reduced memocry usage of package synchronization

updated dependencies
2025-09-16 09:38:18 +08:00
5dcecfef03 updated gradle to 14.2
All checks were successful
CI / build (push) Successful in 33s
2025-06-20 09:03:46 +08:00
2425d4a4ed updated dependencies and switched JWT signature algorithm to ES512
All checks were successful
CI / build (push) Successful in 34s
2025-06-03 22:48:44 +08:00
15 changed files with 60 additions and 38 deletions

View File

@@ -4,14 +4,10 @@ on:
branches: [ master ] branches: [ master ]
jobs: jobs:
build: build:
runs-on: woryzen runs-on: hostinger
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v3 uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build - name: Execute Gradle build

View File

@@ -105,6 +105,7 @@ dependencies {
testImplementation catalog.junit.jupiter.api testImplementation catalog.junit.jupiter.api
testImplementation catalog.junit.jupiter.params testImplementation catalog.junit.jupiter.params
testImplementation catalog.junit.platform.runner
testRuntimeOnly catalog.jakartaee.api testRuntimeOnly catalog.jakartaee.api
testRuntimeOnly catalog.junit.jupiter.engine testRuntimeOnly catalog.junit.jupiter.engine

View File

@@ -1,8 +1,8 @@
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true
jpacrepo.version=2024.04.14 jpacrepo.version=2025.09.15
lys.version=2024.04.14 lys.version=2025.08.15
gitea.maven.url=https://gitea.woggioni.net/api/packages/woggioni/maven gitea.maven.url=https://gitea.woggioni.net/api/packages/woggioni/maven

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

12
gradlew vendored
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
# #
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -112,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;; NONSTOP* ) nonstop=true ;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
@@ -203,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command: # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped. # and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line. # treated as '${Hostname}' itself on the command line.
@@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \ -classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@" "$@"
# Stop when "xargs" is not available. # Stop when "xargs" is not available.

6
gradlew.bat vendored
View File

@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@@ -68,11 +70,11 @@ goto fail
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View File

@@ -83,7 +83,6 @@ public class JpacrepoCli implements Runnable {
} }
prop.put(Context.SECURITY_PRINCIPAL, rpcUsername); prop.put(Context.SECURITY_PRINCIPAL, rpcUsername);
prop.put(Context.SECURITY_CREDENTIALS, rpcPassword); prop.put(Context.SECURITY_CREDENTIALS, rpcPassword);
prop.put("jboss.naming.client.ejb.context", true); prop.put("jboss.naming.client.ejb.context", true);
return new InitialContext(prop); return new InitialContext(prop);
} }

View File

@@ -21,13 +21,13 @@ kotlin {
implementation catalog.khtml implementation catalog.khtml
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-serialization-json', version: '1.6.2' implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-serialization-json', version: '1.6.2'
implementation(npm("bootstrap", "5.3.2")) implementation(npm("bootstrap", "5.3.6"))
implementation(npm("bootstrap-icons", "1.11.3")) implementation(npm("bootstrap-icons", "1.13.1"))
implementation(npm("style-loader", "3.3.4")) implementation(npm("style-loader", "4.0.0"))
implementation(npm("css-loader", "6.10.0")) implementation(npm("css-loader", "7.1.2"))
implementation(npm("postcss-loader", "8.1.0")) implementation(npm("postcss-loader", "8.1.1"))
implementation(npm("sass", "1.71.1")) implementation(npm("sass", "1.89.1"))
implementation(npm("sass-loader", "14.1.1")) implementation(npm("sass-loader", "16.0.5"))
} }
} }
} }

View File

@@ -476,7 +476,7 @@ fun main(vararg args: String) {
} }
footer { footer {
classes("pt-3", "mt-4", "text-body-secondary", "border-top") classes("pt-3", "mt-4", "text-body-secondary", "border-top")
text("©2024") text("©2025")
} }
} }
} }

View File

@@ -34,7 +34,6 @@ import java.nio.file.Path;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletionService; import java.util.concurrent.CompletionService;
@@ -85,10 +84,10 @@ public class PackageSynchronizerEJB implements FileSystemSynchronizer {
logger.info("Starting repository cleanup"); logger.info("Starting repository cleanup");
//Removes from DB the packages that have been deleted from filesystem //Removes from DB the packages that have been deleted from filesystem
logger.info("Searching for packages that are no more in the filesystem"); logger.info("Searching for packages that are no more in the filesystem");
List<String> resultList = Queries.listAllPackageFiles(em) Stream<String> resultList = Queries.listAllPackageFiles(em)
.getResultList(); .getResultStream();
logger.info("Got list of filenames from db"); logger.info("Got list of filenames from db");
Set<String> knownPkg = resultList.stream().filter(fileName -> { Set<String> knownPkg = resultList.filter(fileName -> {
Path file = ctx.getFile(fileName); Path file = ctx.getFile(fileName);
boolean result = Files.exists(file); boolean result = Files.exists(file);
if (!result) { if (!result) {

View File

@@ -16,6 +16,7 @@ import jakarta.ejb.TransactionManagementType;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Query;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import net.woggioni.jpacrepo.api.model.CompressionFormat; import net.woggioni.jpacrepo.api.model.CompressionFormat;
import net.woggioni.jpacrepo.api.model.PkgData; import net.woggioni.jpacrepo.api.model.PkgData;
@@ -79,14 +80,13 @@ public class PacmanServiceEJB implements PacmanServiceLocal {
} }
@SneakyThrows @SneakyThrows
static void deletePackage(AppConfig ctx, EntityManager em, String filename) { static void deletePackage(AppConfig ctx, EntityManager em, String fileName) {
List<PkgData> savedFiles = Queries.getPackageByFileName(em, filename).getResultList(); Query deleteQuery = Queries.deletePackageByFilename(em, fileName);
if (savedFiles.isEmpty()) { final var deletedPackages = deleteQuery.executeUpdate();
throw JWO.newThrowable(IllegalArgumentException.class, "Package with name %s not found", filename); if (deletedPackages == 0) {
throw JWO.newThrowable(IllegalArgumentException.class, "Package with name %s not found", fileName);
} }
PkgData pkg = savedFiles.getFirst(); Files.delete(ctx.getFile(fileName));
em.remove(pkg);
Files.delete(ctx.getFile(pkg));
} }
@Override @Override

View File

@@ -184,7 +184,7 @@ public class PacmanWebService {
@GET @GET
@Path("file/{fileName}") @Path("file/{fileName}")
private Response getPackageByFileName(String fileName) { public Response getPackageByFileName(String fileName) {
try { try {
return Response.ok(service.searchByFileName(fileName)).build(); return Response.ok(service.searchByFileName(fileName)).build();
} catch (NoResultException nre) { } catch (NoResultException nre) {

View File

@@ -2,9 +2,11 @@ package net.woggioni.jpacrepo.service.jpa;
import jakarta.persistence.EntityGraph; import jakarta.persistence.EntityGraph;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.Query;
import jakarta.persistence.Tuple; import jakarta.persistence.Tuple;
import jakarta.persistence.TypedQuery; import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaDelete;
import jakarta.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Path; import jakarta.persistence.criteria.Path;
import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
@@ -328,4 +330,25 @@ public class Queries {
return graph; return graph;
} }
public static Query deletePackagesByFilenames(EntityManager em, Collection<String> fileNames) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaDelete<PkgData> criteriaQuery = cb.createCriteriaDelete(PkgData.class);
Metamodel metamodel = em.getMetamodel();
EntityType<PkgData> entity = metamodel.entity(PkgData.class);
Root<PkgData> root = criteriaQuery.from(entity);
Predicate predicate = root.get(PkgData_.fileName).in(fileNames);
criteriaQuery.where(predicate);
return em.createQuery(criteriaQuery);
}
public static Query deletePackageByFilename(EntityManager em, String fileNames) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaDelete<PkgData> criteriaQuery = cb.createCriteriaDelete(PkgData.class);
Metamodel metamodel = em.getMetamodel();
EntityType<PkgData> entity = metamodel.entity(PkgData.class);
Root<PkgData> root = criteriaQuery.from(entity);
Predicate predicate = cb.equal(root.get(PkgData_.fileName), fileNames);
criteriaQuery.where(predicate);
return em.createQuery(criteriaQuery);
}
} }

View File

@@ -9,6 +9,6 @@
}, },
"verify-token-audience": true, "verify-token-audience": true,
"confidential-port": 443, "confidential-port": 443,
"token-signature-algorithm": "RS256", "token-signature-algorithm": "ES512",
"use-resource-role-mappings": true "use-resource-role-mappings": true
} }