forked from Archives/Athou_commafeed
add an additional day to make sure the timestamp fits in all timezones (#1239)
This commit is contained in:
@@ -25,6 +25,7 @@ import com.commafeed.backend.feed.parser.FeedParserResult.Entry;
|
|||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
import com.commafeed.backend.model.FeedEntry;
|
import com.commafeed.backend.model.FeedEntry;
|
||||||
import com.commafeed.backend.model.FeedSubscription;
|
import com.commafeed.backend.model.FeedSubscription;
|
||||||
|
import com.commafeed.backend.model.Models;
|
||||||
import com.commafeed.backend.model.User;
|
import com.commafeed.backend.model.User;
|
||||||
import com.commafeed.backend.service.FeedEntryService;
|
import com.commafeed.backend.service.FeedEntryService;
|
||||||
import com.commafeed.backend.service.FeedService;
|
import com.commafeed.backend.service.FeedService;
|
||||||
@@ -177,7 +178,7 @@ public class FeedRefreshUpdater {
|
|||||||
|
|
||||||
if (!processed) {
|
if (!processed) {
|
||||||
// requeue asap
|
// requeue asap
|
||||||
feed.setDisabledUntil(Feed.MINIMUM_DISABLED_UNTIL);
|
feed.setDisabledUntil(Models.MINIMUM_INSTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inserted > 0) {
|
if (inserted > 0) {
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
public class Feed extends AbstractModel {
|
public class Feed extends AbstractModel {
|
||||||
|
|
||||||
// mariadb timestamp range starts at 1970-01-01 00:00:01
|
|
||||||
public static final Instant MINIMUM_DISABLED_UNTIL = Instant.EPOCH.plusSeconds(1);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url of the feed
|
* The url of the feed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
package com.commafeed.backend.model;
|
package com.commafeed.backend.model;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
public class Models {
|
public class Models {
|
||||||
|
|
||||||
|
public static final Instant MINIMUM_INSTANT = Instant.EPOCH
|
||||||
|
// mariadb timestamp range starts at 1970-01-01 00:00:01
|
||||||
|
.plusSeconds(1)
|
||||||
|
// make sure the timestamp fits for all timezones
|
||||||
|
.plus(Duration.ofHours(24));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize a proxy
|
* initialize a proxy
|
||||||
*/
|
*/
|
||||||
@@ -18,8 +30,8 @@ public class Models {
|
|||||||
* extract the id from the proxy without initializing it
|
* extract the id from the proxy without initializing it
|
||||||
*/
|
*/
|
||||||
public static Long getId(AbstractModel model) {
|
public static Long getId(AbstractModel model) {
|
||||||
if (model instanceof HibernateProxy) {
|
if (model instanceof HibernateProxy proxy) {
|
||||||
LazyInitializer lazyInitializer = ((HibernateProxy) model).getHibernateLazyInitializer();
|
LazyInitializer lazyInitializer = proxy.getHibernateLazyInitializer();
|
||||||
if (lazyInitializer.isUninitialized()) {
|
if (lazyInitializer.isUninitialized()) {
|
||||||
return (Long) lazyInitializer.getIdentifier();
|
return (Long) lazyInitializer.getIdentifier();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.commafeed.backend.favicon.AbstractFaviconFetcher;
|
|||||||
import com.commafeed.backend.favicon.Favicon;
|
import com.commafeed.backend.favicon.Favicon;
|
||||||
import com.commafeed.backend.feed.FeedUtils;
|
import com.commafeed.backend.feed.FeedUtils;
|
||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
|
import com.commafeed.backend.model.Models;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Singleton;
|
import jakarta.inject.Singleton;
|
||||||
@@ -45,7 +46,7 @@ public class FeedService {
|
|||||||
feed.setUrl(url);
|
feed.setUrl(url);
|
||||||
feed.setNormalizedUrl(normalizedUrl);
|
feed.setNormalizedUrl(normalizedUrl);
|
||||||
feed.setNormalizedUrlHash(normalizedUrlHash);
|
feed.setNormalizedUrlHash(normalizedUrlHash);
|
||||||
feed.setDisabledUntil(Feed.MINIMUM_DISABLED_UNTIL);
|
feed.setDisabledUntil(Models.MINIMUM_INSTANT);
|
||||||
feedDAO.saveOrUpdate(feed);
|
feedDAO.saveOrUpdate(feed);
|
||||||
}
|
}
|
||||||
return feed;
|
return feed;
|
||||||
|
|||||||
Reference in New Issue
Block a user