diff --git a/backend/src/main/java/com/printcalculator/service/SlicerService.java b/backend/src/main/java/com/printcalculator/service/SlicerService.java index 573b668..f09bccf 100644 --- a/backend/src/main/java/com/printcalculator/service/SlicerService.java +++ b/backend/src/main/java/com/printcalculator/service/SlicerService.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -135,12 +136,25 @@ public class SlicerService { Thread.currentThread().interrupt(); throw new IOException("Interrupted during slicing", e); } finally { - // Cleanup temp dir - // In production we should delete, for debugging we might want to keep? - // Let's delete for now on success. - // recursiveDelete(tempDir); - // Leaving it effectively "leaks" temp, but safer for persistent debugging? - // Implementation detail: Use a utility to clean up. + deleteRecursively(tempDir); + } + } + + private void deleteRecursively(Path path) { + if (path == null || !Files.exists(path)) { + return; + } + + try (var walk = Files.walk(path)) { + walk.sorted(Comparator.reverseOrder()).forEach(p -> { + try { + Files.deleteIfExists(p); + } catch (IOException e) { + logger.warning("Failed to delete temp path " + p + ": " + e.getMessage()); + } + }); + } catch (IOException e) { + logger.warning("Failed to walk temp directory " + path + ": " + e.getMessage()); } } } diff --git a/docker-compose.deploy.yml b/docker-compose.deploy.yml index 0b2fcbd..777bdc4 100644 --- a/docker-compose.deploy.yml +++ b/docker-compose.deploy.yml @@ -7,8 +7,6 @@ services: container_name: print-calculator-backend-${ENV} ports: - "${BACKEND_PORT}:8000" - env_file: - - .env environment: - DB_URL=${DB_URL} - DB_USERNAME=${DB_USERNAME} @@ -20,6 +18,7 @@ services: - backend_profiles_${ENV}:/app/profiles - /mnt/cache/appdata/print-calculator/${ENV}/storage_quotes:/app/storage_quotes - /mnt/cache/appdata/print-calculator/${ENV}/storage_orders:/app/storage_orders + - /mnt/cache/appdata/print-calculator/${ENV}/storage_requests:/app/storage_requests frontend: