This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 2bd9d0adb2db2bf0fe342fe74166d526886919db Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Apr 14 12:13:48 2015 +0200 refs #6935 debut de correction --- .../fr/ifremer/tutti/ui/swing/updater/Updater.java | 22 +++++---------- .../ui/swing/updater/UpdaterFileSystemPathes.java | 33 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java index 3198c52..fbb7cc0 100644 --- a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java +++ b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/Updater.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.charset.Charset; -import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -66,7 +65,10 @@ public class Updater { // Get the current directory where application has been launched Path baseDir = Paths.get(System.getProperty("user.dir")); - + if (!baseDir.isAbsolute()) { + baseDir = baseDir.toFile().getAbsoluteFile().toPath(); + } + System.out.println(String.format("Basedir: %s", baseDir)); pathHelper = new UpdaterFileSystemPathes(baseDir); } @@ -245,8 +247,6 @@ public class Updater { pathHelper.removeOlderBackup(updateModule); - Path modulePath = pathHelper.getModulePath(updateModule); - if (moduleExist) { // Backup existing module @@ -254,23 +254,15 @@ public class Updater { } - // Installing new module + // Installing new& module System.out.println(String.format("%s Install new version %s", moduleNameStr, newVersion)); + Path modulePath = pathHelper.getModulePath(updateModule); Path moduleNewPath = pathHelper.getUpdateModulePath(updateModule); try { - try { - - Files.move(moduleNewPath, modulePath, StandardCopyOption.ATOMIC_MOVE); - } catch (AtomicMoveNotSupportedException e) { + pathHelper.move(moduleNewPath, modulePath, true); - // copy atomic impossible - System.out.println(String.format("%s Try fallback install (copy then delete, atomic move is not possible to %s)", moduleNameStr, modulePath)); - Files.copy(moduleNewPath, modulePath, StandardCopyOption.REPLACE_EXISTING); - DeleteHelper.deleteDirectoryOnExit(moduleNewPath); - - } } catch (IOException e) { String message = String.format("La mise à jour du module '%s' a échouée.\nVeuillez contacter un administrateur.", updateModule); diff --git a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java index ef85150..029d543 100644 --- a/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java +++ b/tutti-ui-swing-updater/src/main/java/fr/ifremer/tutti/ui/swing/updater/UpdaterFileSystemPathes.java @@ -27,8 +27,10 @@ package fr.ifremer.tutti.ui.swing.updater; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.nio.file.attribute.PosixFilePermission; import java.text.SimpleDateFormat; import java.util.Date; @@ -200,8 +202,8 @@ public class UpdaterFileSystemPathes { Path backupModulePath = backupDirectory.resolve(String.format("%s-%s-%s", moduleName, version, backupDate)); - System.out.println(String.format("%s Backup old version %s to %s", updateModule.getModuleLoggerName(), version, backupModulePath)); - Files.move(modulePath, backupModulePath); + System.out.println(String.format("%s Backup old version %s from %s to %s", updateModule.getModuleLoggerName(), version, modulePath, backupModulePath)); + move(modulePath, backupModulePath, false); } @@ -226,4 +228,31 @@ public class UpdaterFileSystemPathes { } return lines.get(0); } + + protected void move(Path source, Path target, boolean deleteOnExitAsFallback) throws IOException { + + try { + + Files.move(source.toAbsolutePath(), target.toAbsolutePath(), StandardCopyOption.ATOMIC_MOVE); + + } catch (AtomicMoveNotSupportedException e) { + + // copy atomic impossible + System.out.println(String.format("%s Try fallback install (copy then delete, atomic move is not possible to %s)", source, target)); + Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); + + if (deleteOnExitAsFallback) { + + DeleteHelper.deleteDirectoryOnExit(source); + + } else { + + DeleteHelper.deleteDirectory(source); + + } + + } + + + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.