Skip to content

Commit

Permalink
tried to make last_modified recognition smarter
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed May 21, 2014
1 parent 2d03037 commit 53948da
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/net/yacy/cora/protocol/HeaderFramework.java
Expand Up @@ -492,7 +492,7 @@ public String getContentType() {
protected Date headerDate(final String kind) {
if (containsKey(kind)) {
Date parsedDate = parseHTTPDate(get(kind));
if (parsedDate == null) parsedDate = new Date();
if (parsedDate == null) return null;
return parsedDate;
}
return null;
Expand Down
3 changes: 2 additions & 1 deletion source/net/yacy/cora/protocol/ResponseHeader.java
Expand Up @@ -84,7 +84,8 @@ public Date expires() {

public Date lastModified() {
if (this.date_cache_LastModified != null) return this.date_cache_LastModified;
final Date d = headerDate(HeaderFramework.LAST_MODIFIED);
Date d = headerDate(HeaderFramework.LAST_MODIFIED);
if (d == null) d = date();
final Date now = new Date();
this.date_cache_LastModified = (d == null) ? date() : d.after(now) ? now : d;
return this.date_cache_LastModified;
Expand Down
1 change: 1 addition & 0 deletions source/net/yacy/search/index/Segment.java
Expand Up @@ -529,6 +529,7 @@ public SolrInputDocument storeDocument(

// STORE URL TO LOADED-URL-DB
Date modDate = responseHeader == null ? new Date() : responseHeader.lastModified();
if (modDate == null) modDate = new Date();
if (modDate.getTime() > loadDate.getTime()) modDate = loadDate;
char docType = Response.docType(document.dc_format());

Expand Down
1 change: 1 addition & 0 deletions source/net/yacy/search/schema/CollectionConfiguration.java
Expand Up @@ -468,6 +468,7 @@ public SolrVector yacy2solr(
if (allAttr || contains(CollectionSchema.content_type)) add(doc, CollectionSchema.content_type, new String[]{document.dc_format()});
if (allAttr || contains(CollectionSchema.last_modified)) {
Date lastModified = responseHeader == null ? new Date() : responseHeader.lastModified();
if (lastModified == null) lastModified = new Date();
if (document.getDate().before(lastModified)) lastModified = document.getDate();
add(doc, CollectionSchema.last_modified, lastModified);
}
Expand Down

0 comments on commit 53948da

Please sign in to comment.