Preserve SCP permission modes only if option activated
* According to SCP man entry:
-p     Preserves modification times, access times, and modes from the original file.
@@ -605,7 +605,7 @@ public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Sess
}
Set<PosixFilePermission> perms = EnumSet.copyOf(resolver.getPermissions());
- String octalPerms = GenericUtils.isEmpty(perms) ? DEFAULT_FILE_OCTAL_PERMISSIONS : getOctalPermissions(perms);
+ String octalPerms = (preserve || GenericUtils.isEmpty(perms)) ? DEFAULT_FILE_OCTAL_PERMISSIONS : getOctalPermissions(perms);
String fileName = resolver.getFileName();
String cmd = "C" + octalPerms + " " + fileSize + " " + fileName;
if (log.isDebugEnabled()) {
@@ -700,7 +700,7 @@ public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Sess
LinkOption[] options = IoUtils.getLinkOptions(true);
Set<PosixFilePermission> perms = IoUtils.getPermissions(path, options);
- String octalPerms = GenericUtils.isEmpty(perms) ? DEFAULT_DIR_OCTAL_PERMISSIONS : getOctalPermissions(perms);
+ String octalPerms = (preserve || GenericUtils.isEmpty(perms)) ? DEFAULT_DIR_OCTAL_PERMISSIONS : getOctalPermissions(perms);
String cmd = "D" + octalPerms + " " + "0" + " " + Objects.toString(path.getFileName(), null);
if (log.isDebugEnabled()) {
log.debug("sendDir({})[{}] send 'D' command: {}", this, path, cmd);
