This commit is contained in:
Ludy87 2025-07-19 01:16:15 +02:00
parent 64d8ef4a39
commit d7885fd773
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
5 changed files with 28 additions and 6 deletions

View File

@ -76,8 +76,8 @@ labels:
- 'app/core/src/main/resources/settings.yml.template'
- 'app/core/src/main/resources/application.properties'
- 'app/core/src/main/resources/banner.txt'
- 'scripts/png_to_webp.py'
- 'split_photos.py'
- 'app/core/src/main/resources/static/python/png_to_webp.py'
- 'app/core/src/main/resources/static/python/split_photos.py'
- 'application.properties'
- label: 'Security'
@ -95,8 +95,8 @@ labels:
- 'app/core/src/main/java/stirling/software/SPDF/model/api/.*'
- 'app/core/src/main/java/stirling/software/SPDF/service/ApiDocService.java'
- 'app/proprietary/src/main/java/stirling/software/proprietary/security/controller/api/.*'
- 'scripts/png_to_webp.py'
- 'split_photos.py'
- 'app/core/src/main/resources/static/python/png_to_webp.py'
- 'app/core/src/main/resources/static/python/split_photos.py'
- '.github/workflows/swagger.yml'
- label: 'Documentation'

View File

@ -6,10 +6,10 @@ repos:
args:
- --fix
- --line-length=127
files: ^((\.github/scripts|scripts)/.+)?[^/]+\.py$
files: ^((\.github/scripts|scripts|app/core/src/main/resources/static/python)/.+)?[^/]+\.py$
exclude: (split_photos.py)
- id: ruff-format
files: ^((\.github/scripts|scripts)/.+)?[^/]+\.py$
files: ^((\.github/scripts|scripts|app/core/src/main/resources/static/python)/.+)?[^/]+\.py$
exclude: (split_photos.py)
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1

View File

@ -16,6 +16,7 @@ import java.util.List;
import java.util.Locale;
import java.util.UUID;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternUtils;
@ -442,6 +443,27 @@ public class GeneralUtils {
}
}
/**
* Extracts a file from classpath:/static/python to a temporary directory and returns the
* path.
*/
public static Path extractScript(String scriptName) throws IOException {
// 1. loade the script from classpath
ClassPathResource resource = new ClassPathResource("static/python/" + scriptName);
// 2. create a temporary directory
Path tmpDir = Files.createTempDirectory("stirling-pdf-scripts");
tmpDir.toFile().deleteOnExit();
// 3. Copy the file
Path scriptFile = tmpDir.resolve(scriptName);
try (InputStream in = resource.getInputStream()) {
Files.copy(in, scriptFile, StandardCopyOption.REPLACE_EXISTING);
}
return scriptFile;
}
public static boolean isVersionHigher(String currentVersion, String compareVersion) {
if (currentVersion == null || compareVersion == null) {
return false;