try {
version = Integer.parseInt(sVersion);
} catch (Throwable t) {
}
Pattern pat = Pattern.compile("SCRIPT_VERSION=([0-9]+)",
Pattern.CASE_INSENSITIVE);
File oldFilePath;
String sScriptFile = System.getProperty("azureus.script", null);
if (sScriptFile != null && new File(sScriptFile).exists()) {
oldFilePath = new File(sScriptFile);
} else {
oldFilePath = new File(SystemProperties.getApplicationPath(),
"azureus");
if (!oldFilePath.exists()) {
return;
}
}
final String oldFilePathString = oldFilePath.getAbsolutePath();
String oldStartupScript;
try {
oldStartupScript = FileUtil.readFileAsString(oldFilePath,
65535, "utf8");
} catch (IOException e) {
oldStartupScript = "";
}
// Case: Script with no version, we update it, user selects restart.
// Restart doesn't include azureus.script.version yet, so we
// would normally prompt again. This fix reads the version
// from the file if we don't have a version yet, thus preventing
// the second restart message
if (version == 0) {
Matcher matcher = pat.matcher(oldStartupScript);
if (matcher.find()) {
String sScriptVersion = matcher.group(1);
try {
version = Integer.parseInt(sScriptVersion);
} catch (Throwable t) {
}
}
}
if (version <= lastAskedVersion) {
return;
}
InputStream stream = getClass().getResourceAsStream("startupScript");
try {
String startupScript = FileUtil.readInputStreamAsString(stream, 65535,
"utf8");
Matcher matcher = pat.matcher(startupScript);
if (matcher.find()) {
String sScriptVersion = matcher.group(1);
int latestVersion = 0;
try {
latestVersion = Integer.parseInt(sScriptVersion);