diff --git a/Guify/src/code/SshEngine.java b/Guify/src/code/SshEngine.java index 19dda28..2ca7a39 100644 --- a/Guify/src/code/SshEngine.java +++ b/Guify/src/code/SshEngine.java @@ -173,8 +173,7 @@ public class SshEngine { * Uploads a file from the local machine to the remote host. Executed * asynchronously. */ - public static void uploadFile(File fileToUpload, String remoteDirectory) - throws SftpException { + public static void uploadFile(File fileToUpload, String remoteDirectory) { // We execute the lengthy and time-consuming operation on a different // thread instead of the Event Dispatch Thread. // We use SwingWorker so any GUI changes requested by this thread will diff --git a/Guify/src/controllers/DesktopController.java b/Guify/src/controllers/DesktopController.java index e002dd3..a284a8c 100644 --- a/Guify/src/controllers/DesktopController.java +++ b/Guify/src/controllers/DesktopController.java @@ -3,7 +3,6 @@ package controllers; import com.google.gson.Gson; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.SftpException; - import code.Constants; import code.Constants.Constants_FSOperations; import code.GuiAbstractions.Implementations.JFrameFactory; @@ -71,7 +70,6 @@ public class DesktopController { } public void setLastSafeDirectory(String directory) { - if (directory == null) { lastSafeDirectory = null; return; @@ -150,27 +148,26 @@ public class DesktopController { */ public void uploadToRemoteServer(File[] selectedNodes) throws SftpException { - if (selectedNodes.length > 0) { - List selectedFiles = new ArrayList(); - List selectedDirectories = new ArrayList(); - for (java.io.File file : selectedNodes) { - if (file.isFile()) { - selectedFiles.add(file); - } else if (file.isDirectory()) { - selectedDirectories.add(file); - } + if (selectedNodes.length == 0) { + return; + } + List selectedFiles = new ArrayList(); + List selectedDirectories = new ArrayList(); + for (java.io.File file : selectedNodes) { + if (file.isFile()) { + selectedFiles.add(file); + } else if (file.isDirectory()) { + selectedDirectories.add(file); } + } - for (File file : selectedFiles) { - SshEngine.uploadFile(file, this.getCurrentWorkingDirectory()); - } + for (File file : selectedFiles) { + SshEngine.uploadFile(file, this.getCurrentWorkingDirectory()); + } - if (selectedDirectories.size() > 0) { - for (File directory : selectedDirectories) { - SshEngine.uploadDirectoriesRecursively(directory, - this.getCurrentWorkingDirectory()); - } - } + for (File directory : selectedDirectories) { + SshEngine.uploadDirectoriesRecursively(directory, + this.getCurrentWorkingDirectory()); } } @@ -304,7 +301,7 @@ public class DesktopController { // cannot write on destination // we keep using isWriteable as // the executeCommand() does not fire - // an exception in case of fail + // an exception in case of failure if (!isWriteable(destination)) { return; } diff --git a/Guify/src/views/Desktop.java b/Guify/src/views/Desktop.java index c925b78..1718dec 100644 --- a/Guify/src/views/Desktop.java +++ b/Guify/src/views/Desktop.java @@ -232,6 +232,7 @@ public class Desktop extends JFrame implements IDesktopFrame { * Loads the desktop view * * @throws SftpException + * if the content of the directory cannot be displayed */ private void loadDesktop() throws SftpException { desktopPanel.removeAll();