This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 80e55a53 Add last modified check
80e55a53 is described below

commit 80e55a53a5565de025c90747706ad176d9c005c2
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Thu Dec 7 16:50:29 2023 +0100

    Add last modified check
---
 .../src/main/java/org/apache/sling/offline/impl/Starter.java       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/org.apache.sling.offline/src/main/java/org/apache/sling/offline/impl/Starter.java
 
b/org.apache.sling.offline/src/main/java/org/apache/sling/offline/impl/Starter.java
index 8c10f775..f28375e0 100644
--- 
a/org.apache.sling.offline/src/main/java/org/apache/sling/offline/impl/Starter.java
+++ 
b/org.apache.sling.offline/src/main/java/org/apache/sling/offline/impl/Starter.java
@@ -84,6 +84,12 @@ public class Starter {
             return;
         }
         logger.info("Processing {}", resource.getPath());
+        final long lastModified = 
resource.getResourceMetadata().getModificationTime();
+        final File output = new File(config.output_path(), 
resource.getPath().substring(this.config.input_path().length()).concat(".html"));
+        if ( lastModified > 0 && output.exists() && output.lastModified() >= 
lastModified ) {
+            logger.info("Skipping {} as it is up to date", resource.getPath());
+            return;
+        }
         final long endAt = System.currentTimeMillis() + 5000;
         while ( System.currentTimeMillis() < endAt ) {
             final SlingHttpServletRequest req = 
Builders.newRequestBuilder(resource)
@@ -93,7 +99,6 @@ public class Starter {
             processor.processRequest(req, resp, resolver);
 
             if ( resp.getStatus() == 200 ) {
-                final File output = new File(config.output_path(), 
resource.getPath().substring(this.config.input_path().length()).concat(".html"));
                 logger.info("Writing output to {}", output.getAbsolutePath());
                 output.getParentFile().mkdirs();
                 Files.writeString(output.toPath(), resp.getOutputAsString());

Reply via email to