提交 cd2910a8 编写于 作者: K kohsuke

first time around, check the timestamp from the disk. This would save...

first time around, check the timestamp from the disk. This would save pointless checks during development.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10074 71c3de6d-444a-0410-be80-ed276b4c234a
上级 21642ad4
...@@ -46,6 +46,9 @@ import java.util.logging.Logger; ...@@ -46,6 +46,9 @@ import java.util.logging.Logger;
* @since 1.220 * @since 1.220
*/ */
public class UpdateCenter implements ModelObject { public class UpdateCenter implements ModelObject {
/**
* What's the time stamp of data file?
*/
private long dataTimestamp = -1; private long dataTimestamp = -1;
/** /**
...@@ -79,6 +82,8 @@ public class UpdateCenter implements ModelObject { ...@@ -79,6 +82,8 @@ public class UpdateCenter implements ModelObject {
* Returns true if it's time for us to check for new version. * Returns true if it's time for us to check for new version.
*/ */
public boolean isDue() { public boolean isDue() {
if(dataTimestamp==-1)
dataTimestamp = getDataFile().file.lastModified();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
boolean due = now - dataTimestamp > DAY && now - lastAttempt > 15000; boolean due = now - dataTimestamp > DAY && now - lastAttempt > 15000;
if(due) lastAttempt = now; if(due) lastAttempt = now;
......
...@@ -16,7 +16,7 @@ import java.io.StringWriter; ...@@ -16,7 +16,7 @@ import java.io.StringWriter;
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
public class TextFile { public class TextFile {
private final File file; public final File file;
public TextFile(File file) { public TextFile(File file) {
this.file = file; this.file = file;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册