Skip to content

Commit

Permalink
Refactor Crawler#crawlSourceFile() logic around updating cache flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Oct 30, 2018
1 parent 97b7ea0 commit 629c63b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions jbake-core/src/main/java/org/jbake/app/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.Map;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.jbake.app.Crawler.Attributes.Status;
import org.jbake.app.configuration.JBakeConfiguration;
import org.jbake.app.configuration.JBakeConfigurationFactory;
Expand Down Expand Up @@ -220,8 +221,11 @@ private void crawlSourceFile(final File sourceFile, final String sha1, final Str

ODocument doc = new ODocument(documentType);
doc.fromMap(fileContents);
boolean cached = fileContents.get(String.valueOf(DocumentAttributes.CACHED)) != null ? Boolean.valueOf((String) fileContents.get(String.valueOf(DocumentAttributes.CACHED))) : true;
doc.field(String.valueOf(DocumentAttributes.CACHED), cached);
// This just stores true if it's not there.
String attrCached = DocumentAttributes.CACHED.toString();
String currentValue = (String) fileContents.get(attrCached);
boolean isCached = BooleanUtils.toBoolean(currentValue, null, "false");
doc.field(attrCached, isCached);
doc.save();
}
else {
Expand Down

0 comments on commit 629c63b

Please sign in to comment.