From 1a46659a1d9f105596b618431d3a0c69e4a0b655 Mon Sep 17 00:00:00 2001 From: brinn <brinn> Date: Fri, 29 Feb 2008 22:21:56 +0000 Subject: [PATCH] merged from 1.0.x, r4610 add: support for pre-release versions of rsync (for testing these versions) SVN: 4613 --- .../filesystem/remote/rsync/RsyncCopier.java | 9 ++++- .../remote/rsync/RsyncVersionChecker.java | 38 +++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java index 04e54feeafe..72e107ce370 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java @@ -338,8 +338,13 @@ public class RsyncCopier implements IPathCopier } if (machineLog.isInfoEnabled()) { - machineLog.info(String.format("Using rsync executable '%s', version %s, mode: %s", rsyncExecutable, rsyncVersion - .getVersionString(), (isOverwriteMode() ? "overwrite" : "append"))); + machineLog.info(String.format("Using rsync executable '%s', version %s, mode: %s", rsyncExecutable, + rsyncVersion.getVersionString(), (isOverwriteMode() ? "overwrite" : "append"))); + } + if (rsyncVersion.isRsyncPreReleaseVersion()) + { + machineLog.warn(String.format("The rsync executable '%s' is a pre-release version. It is not recommended " + + "to use such a version in a production environment.", rsyncExecutable)); } } diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncVersionChecker.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncVersionChecker.java index 9e8cc975b40..d1061379a7b 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncVersionChecker.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncVersionChecker.java @@ -64,12 +64,19 @@ final class RsyncVersionChecker */ private final int rsyncPatchVersion; - private RsyncVersion(String rsyncVersion, int rsyncMajorVersion, int rsyncMinorVersion, int rsyncPatchVersion) + /** + * Returns <code>true</code>, if the version is a pre-release version of <code>rsync</code>. + */ + private final boolean rsyncPreReleaseVersion; + + private RsyncVersion(String rsyncVersion, int rsyncMajorVersion, int rsyncMinorVersion, int rsyncPatchVersion, + boolean rsyncPreReleaseVersion) { this.rsyncVersion = rsyncVersion; this.rsyncMajorVersion = rsyncMajorVersion; this.rsyncMinorVersion = rsyncMinorVersion; this.rsyncPatchVersion = rsyncPatchVersion; + this.rsyncPreReleaseVersion = rsyncPreReleaseVersion; } /** @@ -104,6 +111,14 @@ final class RsyncVersionChecker return rsyncPatchVersion; } + /** + * @return <code>true</code>, if this version is a pre-release version. + */ + public boolean isRsyncPreReleaseVersion() + { + return rsyncPreReleaseVersion; + } + /** * @return <code>true</code>, if this version is newer or as new the minimal version specified. */ @@ -155,9 +170,26 @@ final class RsyncVersionChecker } final int rsyncMajorVersion = Integer.parseInt(rsyncVersionParts[0]); final int rsyncMinorVersion = Integer.parseInt(rsyncVersionParts[1]); - final int rsyncPatchVersion = Integer.parseInt(rsyncVersionParts[2]); + int rsyncPatchVersion; + boolean preReleaseVersion = false; + try + { + rsyncPatchVersion = Integer.parseInt(rsyncVersionParts[2]); + } catch (NumberFormatException ex) + { + final int preIdx = rsyncVersionParts[2].indexOf("pre"); + if (preIdx >= 0) + { + rsyncPatchVersion = Integer.parseInt(rsyncVersionParts[2].substring(0, preIdx)); + preReleaseVersion = true; + } else + { + throw ex; + } + } - return new RsyncVersion(rsyncVersion, rsyncMajorVersion, rsyncMinorVersion, rsyncPatchVersion); + return new RsyncVersion(rsyncVersion, rsyncMajorVersion, rsyncMinorVersion, rsyncPatchVersion, + preReleaseVersion); } private static String tryGetRsyncVersion(String rsyncExecutableToCheck) -- GitLab