Author: jflesch
Date: 2007-08-07 16:53:41 +0000 (Tue, 07 Aug 2007)
New Revision: 14515
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
Log:
Try to make the initial board refresh faster
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
2007-08-07 16:37:12 UTC (rev 14514)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
2007-08-07 16:53:41 UTC (rev 14515)
@@ -558,6 +558,39 @@
notifyChange();
}
+
+ private Date getNextRefreshDate(Date originalDate) {
+ Date today = getMidnight(new Date());
+
+ if (originalDate == null)
+ return today;
+
+ /* if the last date was in the future */
+ if (getMidnight(originalDate).getTime() > today.getTime()) {
+ /* TODO : Take in consideration that we could have
+ * MIN_DAYS_IN_THE_FUTURE > 1
+ */
+ /* we stop */
+ return null;
+ }
+
+
+ Date newDate = new Date(originalDate.getTime() - 24*60*60*1000);
+ Date maxInPast = new Date(new Date().getTime() -
((maxDaysInThePast+1) * 24*60*60*1000));
+ Date lastUpdatePast = ((lastUpdate == null) ? null :
+ new Date(lastUpdate.getTime() -
(DAYS_BEFORE_THE_LAST_REFRESH * 24*60*60*1000)));
+
+ if (newDate.getTime() >= maxInPast.getTime()
+ && (lastUpdatePast == null || newDate.getTime() >=
lastUpdatePast.getTime())) {
+ /* date in the limits */
+ return getMidnight(newDate);
+ } else {
+ /* no more in the limits => we do tomorrow and then we
stop */
+ return getMidnight(new Date( (today.getTime()) +
24*60*60*1000));
+ }
+ }
+
+
/**
* only called when a message has finished its download
*/
@@ -660,17 +693,10 @@
if (moveDay) {
Logger.info(this, "no more message to
fetch for this day => moving to another");
- lastDate = new Date(lastDate.getTime()
- 24*60*60*1000);
+ lastDate = getNextRefreshDate(lastDate);
lastRev = -1;
- Date maxInPast = new Date(new
Date().getTime() - ((maxDaysInThePast+1) * 24*60*60*1000));
- Date lastUpdatePast = ((lastUpdate ==
null) ? null :
- new
Date(lastUpdate.getTime() - (DAYS_BEFORE_THE_LAST_REFRESH * 24*60*60*1000)));
-
- if (lastDate.getTime() >=
maxInPast.getTime()
- && (lastUpdatePast == null ||
lastDate.getTime() >= lastUpdatePast.getTime())) {
- /* the date is in the limits */
-
+ if (lastDate != null) {
lastSuccessfulRev =
getLastDownloadedRev(lastDate);
/* we start again */
@@ -682,7 +708,6 @@
}
} else {
- /* the date is out of limits */
endOfRefresh();
}
}
@@ -718,11 +743,11 @@
public void run() {
+ //lastDate = new Date((new Date()).getTime()
+ // + (MIN_DAYS_IN_THE_FUTURE * (24 * 60 * 60 *
1000 /* 1 day */)));
+ lastDate = getNextRefreshDate(null);
lastRev = -1;
- lastDate = new Date((new Date()).getTime()
- + (MIN_DAYS_IN_THE_FUTURE * (24 * 60 * 60 *
1000 /* 1 day */)));
-
synchronized(runningDownloads) {
lastSuccessfulRev = getLastDownloadedRev(lastDate);