mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d42534d26 | ||
|
|
63b64b5dc5 | ||
|
|
1d47f5e26a | ||
|
|
2a20ffd09a | ||
|
|
47a49c5353 | ||
|
|
17ef9720e5 |
@@ -88,7 +88,7 @@ jobs:
|
||||
|
||||
- name: Generate tags
|
||||
id: meta
|
||||
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
|
||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||
if: github.ref != 'refs/heads/main'
|
||||
with:
|
||||
images: |
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
|
||||
- name: Generate tags ultra-lite
|
||||
id: meta2
|
||||
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
|
||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||
if: github.ref != 'refs/heads/main'
|
||||
with:
|
||||
images: |
|
||||
@@ -165,7 +165,7 @@ jobs:
|
||||
|
||||
- name: Generate tags fat
|
||||
id: meta3
|
||||
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
|
||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||
with:
|
||||
images: |
|
||||
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
||||
|
||||
@@ -41,5 +41,5 @@ dependencies {
|
||||
api 'org.snakeyaml:snakeyaml-engine:2.10'
|
||||
api "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.9"
|
||||
api 'jakarta.mail:jakarta.mail-api:2.1.3'
|
||||
runtimeOnly 'org.eclipse.angus:angus-mail:2.0.3'
|
||||
runtimeOnly 'org.eclipse.angus:angus-mail:2.0.4'
|
||||
}
|
||||
|
||||
+56
-4
@@ -56,13 +56,20 @@ public class TempFileCleanupService {
|
||||
|| fileName.startsWith("pdf-stream-")
|
||||
|| fileName.startsWith("PDFBox")
|
||||
|| fileName.startsWith("input_")
|
||||
|| fileName.startsWith("overlay-");
|
||||
|| fileName.startsWith("overlay-")
|
||||
|| fileName.startsWith("signature")
|
||||
|| fileName.startsWith("original_")
|
||||
|| fileName.startsWith("preprocessed_")
|
||||
|| fileName.startsWith("temp")
|
||||
|| fileName.startsWith("gs_")
|
||||
|| fileName.startsWith("MultiPart");
|
||||
|
||||
// File patterns that identify common system temp files
|
||||
private static final Predicate<String> IS_SYSTEM_TEMP_FILE =
|
||||
fileName ->
|
||||
fileName.matches("lu\\d+[a-z0-9]*\\.tmp")
|
||||
fileName.matches("lu\\d+[a-z0-9]*(\\.tmp)?")
|
||||
|| fileName.matches("ocr_process\\d+")
|
||||
|| fileName.contains("ocrmypdf.io.")
|
||||
|| (fileName.startsWith("tmp") && !fileName.contains("jetty"))
|
||||
|| fileName.startsWith("OSL_PIPE_")
|
||||
|| (fileName.endsWith(".tmp") && !fileName.contains("jetty"));
|
||||
@@ -70,8 +77,9 @@ public class TempFileCleanupService {
|
||||
// File patterns that should be excluded from cleanup
|
||||
private static final Predicate<String> SHOULD_SKIP =
|
||||
fileName ->
|
||||
fileName.contains("jetty")
|
||||
|| fileName.startsWith("jetty-")
|
||||
(fileName.contains("jetty")
|
||||
&& !fileName.startsWith("jetty-0_0_0_0-8080--_-any-"))
|
||||
|| fileName.startsWith("jetty-docbase")
|
||||
|| "proc".equals(fileName)
|
||||
|| "sys".equals(fileName)
|
||||
|| "dev".equals(fileName)
|
||||
@@ -395,6 +403,18 @@ public class TempFileCleanupService {
|
||||
log.debug("Could not check file info, skipping: {}", path);
|
||||
}
|
||||
|
||||
// Fallback: if file is in our managed temp directories and older than maxAge, delete it
|
||||
// regardless of filename pattern (this catches any temp files we might have missed)
|
||||
if (!shouldDelete && maxAgeMillis > 0 && lastModified > 0) {
|
||||
boolean isInManagedTempDir = isInManagedTempDirectory(path);
|
||||
boolean isOlderThanMaxAge = (currentTime - lastModified) > maxAgeMillis;
|
||||
|
||||
if (isInManagedTempDir && isOlderThanMaxAge) {
|
||||
shouldDelete = true;
|
||||
log.debug("Deleting old file in managed temp directory: {}", path);
|
||||
}
|
||||
}
|
||||
|
||||
// Check file age against maxAgeMillis only if it's not an empty file that we've already
|
||||
// decided to delete
|
||||
if (!isEmptyFile && shouldDelete && maxAgeMillis > 0) {
|
||||
@@ -405,6 +425,38 @@ public class TempFileCleanupService {
|
||||
return shouldDelete;
|
||||
}
|
||||
|
||||
/** Check if a path is within one of our managed temp directories. */
|
||||
private boolean isInManagedTempDirectory(Path path) {
|
||||
try {
|
||||
ApplicationProperties.TempFileManagement tempFiles =
|
||||
applicationProperties.getSystem().getTempFileManagement();
|
||||
|
||||
String baseTmpDir = tempFiles.getBaseTmpDir();
|
||||
String libreOfficeDir = tempFiles.getLibreofficeDir();
|
||||
|
||||
// Check if path is under our main temp directory
|
||||
if (baseTmpDir != null && !baseTmpDir.isEmpty()) {
|
||||
Path baseTempPath = Path.of(baseTmpDir).toAbsolutePath().normalize();
|
||||
if (path.toAbsolutePath().normalize().startsWith(baseTempPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if path is under LibreOffice temp directory
|
||||
if (libreOfficeDir != null && !libreOfficeDir.isEmpty()) {
|
||||
Path libreOfficePath = Path.of(libreOfficeDir).toAbsolutePath().normalize();
|
||||
if (path.toAbsolutePath().normalize().startsWith(libreOfficePath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.debug("Error checking if path is in managed temp directory: {}", path, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Clean up LibreOffice temporary files. This method is called after LibreOffice operations. */
|
||||
public void cleanupLibreOfficeTempFiles() {
|
||||
// Cleanup known LibreOffice temp directories
|
||||
|
||||
@@ -41,7 +41,7 @@ dependencies {
|
||||
api 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
api 'org.springframework.boot:spring-boot-starter-oauth2-client'
|
||||
api 'org.springframework.boot:spring-boot-starter-mail'
|
||||
api 'io.swagger.core.v3:swagger-core-jakarta:2.2.34'
|
||||
api 'io.swagger.core.v3:swagger-core-jakarta:2.2.35'
|
||||
implementation 'com.bucket4j:bucket4j_jdk17-core:8.14.0'
|
||||
|
||||
// https://mvnrepository.com/artifact/com.bucket4j/bucket4j_jdk17
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ ext {
|
||||
bouncycastleVersion = "1.81"
|
||||
springSecuritySamlVersion = "6.5.2"
|
||||
openSamlVersion = "4.3.2"
|
||||
commonmarkVersion = "0.25.0"
|
||||
commonmarkVersion = "0.25.1"
|
||||
googleJavaFormatVersion = "1.28.0"
|
||||
tempJrePath = null
|
||||
}
|
||||
|
||||
@@ -1027,4 +1027,6 @@ ignore = [
|
||||
[zh_TW]
|
||||
ignore = [
|
||||
'language.direction',
|
||||
'poweredBy',
|
||||
'showJS.tags',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user