From 49aa9ac936e07937b7e08b17759f904e2f10d3fb Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 20 Sep 2007 19:31:21 +0000
Subject: [PATCH] Fix for issue 2227 in which unpredictable behavior results from an upgrade or reversion process replacing the upgrade script while the upgrade process is running on Windows. This code will compare the running version of the script with the new version to see whether or not the script actually needs replacing. If so the script is copied with an extension NEW. When the script starts it checks for the existence of upgrade.bat.NEW and if exists prints a message informing the user that they must replace the old version of the script with the new version before continuing.
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
index 8379c04..78813cd 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
@@ -353,6 +353,33 @@
filter);
}
+ /**
+ * Determines whether or not two files differ in content.
+ *
+ * @param f1 file to compare
+ * @param f2 file to compare
+ * @return boolean where true indicates that two files differ
+ * @throws IOException if there is a problem reading the files' conents
+ */
+ public boolean filesDiffer(File f1, File f2) throws IOException {
+ boolean differ = false;
+ FileReader fr1 = new FileReader(f1);
+ FileReader fr2 = new FileReader(f2);
+ try {
+ boolean done = false;
+ while (!differ && !done) {
+ int c1 = fr1.read();
+ int c2 = fr2.read();
+ differ = c1 != c2;
+ done = c1 == -1 || c2 == -1;
+ }
+ } finally {
+ fr1.close();
+ fr2.close();
+ }
+ return differ;
+ }
+
private void operateRecursively(FileOperation op, FileFilter filter)
throws ApplicationException {
File file = op.getObjectFile();
--
Gitblit v1.10.0