blob: 235a4b4f379862779b5988c4ddfe9ccad7b84f93 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
package NET.worlds.network;
import NET.worlds.core.IniFile;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URLConnection;
import java.util.Hashtable;
public class DirTimeStamp {
private static Hashtable<URL, DirTimeStamp> _tsEntries = new Hashtable<URL, DirTimeStamp>();
private URL _name;
private long _mtime;
private boolean _loaded = false;
private DirTimeStamp(URL url) {
this._name = url;
assert url.isRemote();
}
private static synchronized DirTimeStamp lookup(URL url) {
DirTimeStamp t = _tsEntries.get(url);
if (t == null) {
t = new DirTimeStamp(url);
_tsEntries.put(url, t);
}
return t;
}
private void getMTime() {
this._mtime = 0L;
try {
int r = (int)(Math.random() * 1000000.0);
int retryCount = IniFile.gamma().getIniInt("NetCacheRetries", 1);
boolean offline = CacheEntry.getOffline();
if (offline) {
this._loaded = true;
return;
}
if (offline) {
retryCount = 1;
}
java.net.URL u = DNSLookup.lookup(new java.net.URL(this._name.unalias() + "?" + r));
while (true) {
try {
URLConnection uc = u.openConnection();
this._mtime = uc.getLastModified();
break;
} catch (IOException var7) {
if (--retryCount <= 0 || var7 instanceof FileNotFoundException) {
throw var7;
}
System.out.println("Exception " + var7 + " querying " + this._name + ", retrying...");
}
}
this._loaded = true;
} catch (FileNotFoundException var8) {
System.out.println("Warning: timestamp " + this._name + " not found.");
this._loaded = true;
} catch (Exception var9) {
System.out.println("Timestamp query error: " + var9 + " accessing " + this._name);
this._loaded = true;
}
}
public static long request(URL url) {
URL tsURL = URL.make(url, "timestamp.dir");
String u = url.getInternal();
int i = u.lastIndexOf(47);
if (i > 0) {
int j = u.lastIndexOf(47, i - 1) + 1;
if (j > 11) {
String par = u.substring(j, i);
if (url.endsWith("upgrades.lst")) {
if (!par.equals("gdkup") && !par.equals("newup") && !par.equals("3DCDup")) {
tsURL = URL.make(u.substring(0, j) + "timestamp.upgrades");
} else {
tsURL = URL.make(url, "timestamp.upgrades");
}
} else if (par.equals("cgi-bin")) {
return 0L;
}
}
}
DirTimeStamp t = lookup(tsURL);
synchronized (t) {
if (!t._loaded) {
t.getMTime();
}
}
return t._mtime;
}
}
|